mmc: dw_mmc: add dw_mmc-k3
v3 cover mmc: dw_mmc: add dw_mmc-k3
v3:
0001:
Put set/clear_bit DW_MMC_CARD_PRESENT in dw_mci_get_cd, Since dw_mci_request will check DW_MMC_CARD_PRESENT before sending cmd
0002:
Follow suggestion from Chris, Kumar and Seungwon
Sync to latest mmc-next, which is 3.12-rc2
Remove enum dw_mci_k3_type etc
v2:
Follow Jaehoon's suggestion
Use slot-gpio.c handle cd pin
Move table out to dts
other suggestion
Zhangfei Gao (2):
mmc: dw_mmc: add dw_mci_of_get_cd_gpio to handle cd pin
mmc: dw_mmc: add dw_mmc-k3 for k3 platform
.../devicetree/bindings/mmc/k3-dw-mshc.txt | 83 +++++++ drivers/mmc/host/Kconfig | 10 + drivers/mmc/host/Makefile | 1 + drivers/mmc/host/dw_mmc-k3.c | 247 ++++++++++++++++++++ drivers/mmc/host/dw_mmc.c | 52 +++-- 5 files changed, 380 insertions(+), 13 deletions(-) create mode 100644 Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt create mode 100644 drivers/mmc/host/dw_mmc-k3.c
Signature · 1 line
1.7.9.5
PATCH v3 1/2 mmc: dw_mmc: add dw_mci_of_get_cd_gpio to handle cd pin
Add function dw_mci_of_get_cd_gpio to check "cd-gpios" from dts. mmc_gpio_request_cd and mmc_gpio_get_cd are used to handle cd pin
--- drivers/mmc/host/dw_mmc.c | 52 +++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 13 deletions(-)
drivers/mmc/host/dw_mmc.c +39 -13
@@ -36,6 +36,7 @@#include <linux/workqueue.h> #include <linux/of.h> #include <linux/of_gpio.h> +#include <linux/mmc/slot-gpio.h> #include "dw_mmc.h"
@@ -1032,20 +1033,26 @@ static int dw_mci_get_cd(struct mmc_host *mmc)int present;struct dw_mci_slot *slot =mmc_priv (mmc);struct dw_mci_board *brd = slot->host->pdata; +int gpio_cd = !mmc_gpio_get_cd (mmc);/* Use platform get_cd function, else try onboard card detect */ if (brd->quirks &DW_MCI_QUIRK_BROKEN_CARD_DETECTION ) present =1 ;else if (brd->get_cd) present = !brd->get_cd (slot->id); +else if (!IS_ERR_VALUE (gpio_cd)) + present = !!gpio_cd;else present = (mci_readl (slot->host,CDETECT ) & (1 << slot->id)) ==0 ?1 :0 ; -if (present) +if (present) { +set_bit (DW_MMC_CARD_PRESENT , &slot->flags);dev_dbg (&mmc->class_dev,"card is present\n" ); -else + }else { +clear_bit (DW_MMC_CARD_PRESENT , &slot->flags);dev_dbg (&mmc->class_dev,"card is not present\n" ); + }return present; }
@@ -1926,10 +1933,6 @@ static void dw_mci_work_routine_card(struct work_struct *work)/* Card change detected */ slot->last_detect_state = present; -/* Mark card as present if applicable */ -if (present !=0 ) -set_bit (DW_MMC_CARD_PRESENT , &slot->flags); -/* Clean up queue if present */ mrq = slot->mrq;if (mrq) {
@@ -1977,8 +1980,6 @@ static void dw_mci_work_routine_card(struct work_struct *work)/* Power down slot */ if (present ==0 ) { -clear_bit (DW_MMC_CARD_PRESENT , &slot->flags); -/* Clear down the FIFO */ dw_mci_fifo_reset (host);#ifdef CONFIG_MMC_DW_IDMAC
@@ -2079,6 +2080,30 @@ static int dw_mci_of_get_wp_gpio(struct device *dev, u8 slot) return gpio; } + +/* find the cd gpio for a given slot; or -1 if none specified */ +static int dw_mci_of_get_cd_gpio (struct device *dev,u8 slot, +struct mmc_host *mmc) +{ +struct device_node *np =dw_mci_of_find_slot_node (dev, slot); +int gpio; + +if (!np) +return -EINVAL ; + + gpio =of_get_named_gpio (np,"cd-gpios" ,0 ); + +/* Having a missing entry is valid; return silently */ +if (!gpio_is_valid (gpio)) +return -EINVAL ; + +if (mmc_gpio_request_cd (mmc, gpio,0 )) { +dev_warn (dev,"gpio [%d] request failed\n" , gpio); +return -EINVAL ; + } + +return gpio; +}#else /* CONFIG_OF */ static int dw_mci_of_get_slot_quirks (struct device *dev,u8 slot) {
@@ -2096,6 +2121,11 @@ static int dw_mci_of_get_wp_gpio(struct device *dev, u8 slot) {return -EINVAL ; } +static int dw_mci_of_get_cd_gpio (struct device *dev,u8 slot, +struct mmc_host *mmc) +{ +return -EINVAL ; +}#endif /* CONFIG_OF */ static int dw_mci_init_slot (struct dw_mci *host,unsigned int id)
@@ -2197,12 +2227,8 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)#endif /* CONFIG_MMC_DW_IDMAC */ } -if (dw_mci_get_cd (mmc)) -set_bit (DW_MMC_CARD_PRESENT , &slot->flags); -else -clear_bit (DW_MMC_CARD_PRESENT , &slot->flags); - slot->wp_gpio =dw_mci_of_get_wp_gpio (host->dev, slot->id); +dw_mci_of_get_cd_gpio (host->dev, slot->id, mmc); ret =mmc_add_host (mmc);if (ret)
Signature · 1 line
1.7.9.5
PATCH v3 1/2 mmc: dw_mmc: add dw_mci_of_get_cd_gpio to handle cd pin
Change function dw_mci_of_get_cd_gpio type to void suggested by Jaehoon And check any other comments
Thanks
Add function dw_mci_of_get_cd_gpio to check "cd-gpios" from dts. mmc_gpio_request_cd and mmc_gpio_get_cd are used to handle cd pin
--- drivers/mmc/host/dw_mmc.c | 48 +++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 13 deletions(-)
drivers/mmc/host/dw_mmc.c +35 -13
@@ -36,6 +36,7 @@#include <linux/workqueue.h> #include <linux/of.h> #include <linux/of_gpio.h> +#include <linux/mmc/slot-gpio.h> #include "dw_mmc.h"
@@ -1032,20 +1033,26 @@ static int dw_mci_get_cd(struct mmc_host *mmc)int present;struct dw_mci_slot *slot =mmc_priv (mmc);struct dw_mci_board *brd = slot->host->pdata; +int gpio_cd = !mmc_gpio_get_cd (mmc);/* Use platform get_cd function, else try onboard card detect */ if (brd->quirks &DW_MCI_QUIRK_BROKEN_CARD_DETECTION ) present =1 ;else if (brd->get_cd) present = !brd->get_cd (slot->id); +else if (!IS_ERR_VALUE (gpio_cd)) + present = !!gpio_cd;else present = (mci_readl (slot->host,CDETECT ) & (1 << slot->id)) ==0 ?1 :0 ; -if (present) +if (present) { +set_bit (DW_MMC_CARD_PRESENT , &slot->flags);dev_dbg (&mmc->class_dev,"card is present\n" ); -else + }else { +clear_bit (DW_MMC_CARD_PRESENT , &slot->flags);dev_dbg (&mmc->class_dev,"card is not present\n" ); + }return present; }
@@ -1926,10 +1933,6 @@ static void dw_mci_work_routine_card(struct work_struct *work)/* Card change detected */ slot->last_detect_state = present; -/* Mark card as present if applicable */ -if (present !=0 ) -set_bit (DW_MMC_CARD_PRESENT , &slot->flags); -/* Clean up queue if present */ mrq = slot->mrq;if (mrq) {
@@ -1977,8 +1980,6 @@ static void dw_mci_work_routine_card(struct work_struct *work)/* Power down slot */ if (present ==0 ) { -clear_bit (DW_MMC_CARD_PRESENT , &slot->flags); -/* Clear down the FIFO */ dw_mci_fifo_reset (host);#ifdef CONFIG_MMC_DW_IDMAC
@@ -2079,6 +2080,26 @@ static int dw_mci_of_get_wp_gpio(struct device *dev, u8 slot) return gpio; } + +/* find the cd gpio for a given slot; or -1 if none specified */ +static void dw_mci_of_get_cd_gpio (struct device *dev,u8 slot, +struct mmc_host *mmc) +{ +struct device_node *np =dw_mci_of_find_slot_node (dev, slot); +int gpio; + +if (!np) +return ; + + gpio =of_get_named_gpio (np,"cd-gpios" ,0 ); + +/* Having a missing entry is valid; return silently */ +if (!gpio_is_valid (gpio)) +return ; + +if (mmc_gpio_request_cd (mmc, gpio,0 )) +dev_warn (dev,"gpio [%d] request failed\n" , gpio); +}#else /* CONFIG_OF */ static int dw_mci_of_get_slot_quirks (struct device *dev,u8 slot) {
@@ -2096,6 +2117,11 @@ static int dw_mci_of_get_wp_gpio(struct device *dev, u8 slot) {return -EINVAL ; } +static void dw_mci_of_get_cd_gpio (struct device *dev,u8 slot, +struct mmc_host *mmc) +{ +return ; +}#endif /* CONFIG_OF */ static int dw_mci_init_slot (struct dw_mci *host,unsigned int id)
@@ -2197,12 +2223,8 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)#endif /* CONFIG_MMC_DW_IDMAC */ } -if (dw_mci_get_cd (mmc)) -set_bit (DW_MMC_CARD_PRESENT , &slot->flags); -else -clear_bit (DW_MMC_CARD_PRESENT , &slot->flags); - slot->wp_gpio =dw_mci_of_get_wp_gpio (host->dev, slot->id); +dw_mci_of_get_cd_gpio (host->dev, slot->id, mmc); ret =mmc_add_host (mmc);if (ret)
Signature · 1 line
1.7.9.5
Jaehoon Chung
maintainerPATCH 1/2 mmc: dw_mmc: add dw_mci_of_get_cd_gpio to handle cd pin
Quoted 129 lines · Zhangfei Gao
Change function
dw_mci_of_get_cd_gpiotype to void suggested by Jaehoon And check any other commentsThanks
Add function
dw_mci_of_get_cd_gpioto check "cd-gpios" from dts.mmc_gpio_request_cdandmmc_gpio_get_cdare used to handle cd pinSigned-off-by Zhangfei Gao <[email protected]>CC Jaehoon Chung <[email protected]>--- drivers/mmc/host/dw_mmc.c | 48 +++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 13 deletions(-)drivers/mmc/host/dw_mmc.c +35
-13@@ -36,6 +36,7 @@#include <linux/workqueue.h> #include <linux/of.h> #include <linux/of_gpio.h> +#include <linux/mmc/slot-gpio.h> #include "dw_mmc.h" @@ -1032,20 +1033,26 @@ static int dw_mci_get_cd(struct mmc_host *mmc)int present;struct dw_mci_slot *slot =mmc_priv (mmc);struct dw_mci_board *brd = slot->host->pdata; +int gpio_cd = !mmc_gpio_get_cd (mmc);/* Use platform get_cd function, else try onboard card detect */ if (brd->quirks &DW_MCI_QUIRK_BROKEN_CARD_DETECTION ) present =1 ;else if (brd->get_cd) present = !brd->get_cd (slot->id); +else if (!IS_ERR_VALUE (gpio_cd)) + present = !!gpio_cd;else present = (mci_readl (slot->host,CDETECT ) & (1 << slot->id)) ==0 ?1 :0 ; -if (present) +if (present) { +set_bit (DW_MMC_CARD_PRESENT , &slot->flags);dev_dbg (&mmc->class_dev,"card is present\n" ); -else + }else { +clear_bit (DW_MMC_CARD_PRESENT , &slot->flags);dev_dbg (&mmc->class_dev,"card is not present\n" ); + }return present; }@@ -1926,10 +1933,6 @@ static void dw_mci_work_routine_card(struct work_struct *work)/* Card change detected */ slot->last_detect_state = present; -/* Mark card as present if applicable */ -if (present !=0 ) -set_bit (DW_MMC_CARD_PRESENT , &slot->flags); -/* Clean up queue if present */ mrq = slot->mrq;if (mrq) {@@ -1977,8 +1980,6 @@ static void dw_mci_work_routine_card(struct work_struct *work)/* Power down slot */ if (present ==0 ) { -clear_bit (DW_MMC_CARD_PRESENT , &slot->flags); -/* Clear down the FIFO */ dw_mci_fifo_reset (host);#ifdef CONFIG_MMC_DW_IDMAC @@ -2079,6 +2080,26 @@ static int dw_mci_of_get_wp_gpio(struct device *dev, u8 slot) return gpio; } + +/* find the cd gpio for a given slot; or -1 if none specified */ +static void dw_mci_of_get_cd_gpio (struct device *dev,u8 slot, +struct mmc_host *mmc) +{ +struct device_node *np =dw_mci_of_find_slot_node (dev, slot); +int gpio; + +if (!np) +return ; + + gpio =of_get_named_gpio (np,"cd-gpios" ,0 ); + +/* Having a missing entry is valid; return silently */ +if (!gpio_is_valid (gpio)) +return ; + +if (mmc_gpio_request_cd (mmc, gpio,0 )) +dev_warn (dev,"gpio [%d] request failed\n" , gpio); +}#else /* CONFIG_OF */ static int dw_mci_of_get_slot_quirks (struct device *dev,u8 slot) {@@ -2096,6 +2117,11 @@ static int dw_mci_of_get_wp_gpio(struct device *dev, u8 slot) {return -EINVAL ; } +static void dw_mci_of_get_cd_gpio (struct device *dev,u8 slot, +struct mmc_host *mmc) +{ +return ; +}#endif /* CONFIG_OF */ static int dw_mci_init_slot (struct dw_mci *host,unsigned int id)@@ -2197,12 +2223,8 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)#endif /* CONFIG_MMC_DW_IDMAC */ } -if (dw_mci_get_cd (mmc)) -set_bit (DW_MMC_CARD_PRESENT , &slot->flags); -else -clear_bit (DW_MMC_CARD_PRESENT , &slot->flags); - slot->wp_gpio =dw_mci_of_get_wp_gpio (host->dev, slot->id); +dw_mci_of_get_cd_gpio (host->dev, slot->id, mmc); ret =mmc_add_host (mmc);if (ret)
PATCH v3 2/2 mmc: dw_mmc: add dw_mmc-k3 for k3 platform
In reply to Zhangfei GaoAdd dw_mmc-k3.c for k3v2, support sd/emmc
--- .../devicetree/bindings/mmc/k3-dw-mshc.txt | 83 +++++++ drivers/mmc/host/Kconfig | 10 + drivers/mmc/host/Makefile | 1 + drivers/mmc/host/dw_mmc-k3.c | 247 ++++++++++++++++++++ 4 files changed, 341 insertions(+) create mode 100644 Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt create mode 100644 drivers/mmc/host/dw_mmc-k3.c
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt new file +83 -0
@@ -0,0 +1,83 @@ +* Hisilicon specific extensions to the Synopsys Designware Mobile + Storage Host Controller + +Read synopsis-dw-mshc.txt for more details +The Synopsys designware mobile storage host controller is used to interface +a SoC with storage medium such as eMMC or SD/MMC cards. This file documents +differences between the core Synopsys dw mshc controller properties described +by synopsis-dw-mshc.txt and the properties used by the Hisilicon specific +extensions to the Synopsys Designware Mobile Storage Host Controller. + +Required Properties: + +* compatible: should be + - "hisilicon,hi4511-dw-mshc": for controllers with hi4511 + specific extentions. +* reg: should be address and size of mmc controller +* vmmc-supply: should be vmmc used in dwmmc +* fifo-depth: should be provided if register can not provide correct value +* tuning-table: should be array to tune mmc controller, including clock rate + to be set and values for setting optional register. + +Optional properties: + +/* These registers from pctrl node used for tuning mmc controller if required */ +* clken-reg: should be clock enable register and offset bit +* drv-sel-reg: should be driver delay select register, start bit and bits numbers +* sam-sel-reg: should be sample delay select register, start bit and bits numbers +* div-reg: should be divider register, start bit and bits numbers + +Example: + + /* SoC portion */ + dwmmc_0: dwmmc0 at fcd03000 { + compatible = "hisilicon,hi4511-dw-mshc"; + reg = <0xfcd03000 0x1000>; + interrupts = <0 16 4>; + #address-cells = <1>; + #size-cells = <0>; + clocks = <&clk_sd>, <&clk_ddrc_per>; + clock-names = "ciu", "biu"; + clken-reg = <0x1f8 0>; + drv-sel-reg = <0x1f8 4 4>; + sam-sel-reg = <0x1f8 8 4>; + div-reg = <0x1f8 1 3>; + tuning-table = + <180000000 6 6 13 13 25000000>, + <0 0 0 0 0 0>, + <360000000 6 4 2 0 50000000>, + <180000000 6 4 13 13 25000000>, + <360000000 6 4 2 0 50000000>, + <720000000 6 1 9 4 100000000>, + <0 0 0 0 0 0>, + <360000000 7 1 3 0 50000000>; + }; + + /* Board portion */ + dwmmc0 at fcd03000 { + num-slots = <1>; + vmmc-supply = <&ldo12>; + fifo-depth = <0x100>; + supports-highspeed; + pinctrl-names = "default"; + pinctrl-0 = <&sd_pmx_pins &sd_cfg_func1 &sd_cfg_func2>; + slot at 0 { + reg = <0>; + bus-width = <4>; + disable-wp; + cd-gpios = <&gpio10 3 0>; + }; + }; + +PCTRL: Peripheral misc control register + +Required Properties: +- compatible: "hisilicon,pctrl" +- reg: Address and size of pctrl. + +Example: + + pctrl: pctrl at fca09000 { + compatible = "hisilicon,pctrl"; + reg = <0xfca09000 0x1000>; + };
drivers/mmc/host/Kconfig +10 -0
@@ -575,6 +575,16 @@ config MMC_DW_SOCFPGA This selects support for Altera SoCFPGA specific extensions to the Synopsys DesignWare Memory Card Interface driver. +config MMC_DW_K3 + tristate "K3 specific extensions for Synopsys DW Memory Card Interface" + depends on MMC_DW + select MMC_DW_PLTFM + select MMC_DW_IDMAC + help + This selects support for Hisilicon K3 SoC specific extensions to the + Synopsys DesignWare Memory Card Interface driver. Select this option + for platforms based on Hisilicon K3 SoC's. + config MMC_DW_PCI tristate "Synopsys Designware MCI support on PCI bus" depends on MMC_DW && PCI
drivers/mmc/host/Makefile +1 -0
@@ -43,6 +43,7 @@ obj-$(CONFIG_MMC_DW) += dw_mmc.o obj-$(CONFIG_MMC_DW_PLTFM) += dw_mmc-pltfm.o obj-$(CONFIG_MMC_DW_EXYNOS) += dw_mmc-exynos.o obj-$(CONFIG_MMC_DW_SOCFPGA) += dw_mmc-socfpga.o +obj-$(CONFIG_MMC_DW_K3) += dw_mmc-k3.o obj-$(CONFIG_MMC_DW_PCI) += dw_mmc-pci.o obj-$(CONFIG_MMC_SH_MMCIF) += sh_mmcif.o obj-$(CONFIG_MMC_JZ4740) += jz4740_mmc.o
drivers/mmc/host/dw_mmc-k3.c new file +247 -0
247 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 2/2 mmc: dw_mmc: add dw_mmc-k3 for k3 platform
Quoted 30 lines · Zhangfei Gao
Add
dw_mmc-k3.cfor k3v2, support sd/emmcSigned-off-by Zhangfei Gao <[email protected]>Tested-by Zhigang Wang <[email protected]>--- .../devicetree/bindings/mmc/k3-dw-mshc.txt | 83 +++++++ drivers/mmc/host/Kconfig | 10 + drivers/mmc/host/Makefile | 1 + drivers/mmc/host/dw_mmc-k3.c | 247 ++++++++++++++++++++ 4 files changed, 341 insertions(+) create mode 100644 Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt create mode 100644 drivers/mmc/host/dw_mmc-k3.cDocumentation/devicetree/bindings/mmc/k3-dw-mshc.txt new file +10
-0@@ -0,0 +1,83 @@ +* Hisilicon specific extensions to the Synopsys Designware Mobile + Storage Host Controller + +Read synopsis-dw-mshc.txt for more details +The Synopsys designware mobile storage host controller is used to interface +a SoC with storage medium such as eMMC or SD/MMC cards. This file documents +differences between the core Synopsys dw mshc controller properties described +by synopsis-dw-mshc.txt and the properties used by the Hisilicon specific +extensions to the Synopsys Designware Mobile Storage Host Controller. +
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt line 20
Quoted 10 lines
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt new file +10
-0+Required Properties: + +* compatible: should be + - "hisilicon,hi4511-dw-mshc": for controllers with hi4511 + specific extentions. +* reg: should be address and size of mmc controller +* vmmc-supply: should be vmmc used in dwmmc +* fifo-depth: should be provided if register can not provide correct value +* tuning-table: should be array to tune mmc controller, including clock rate + to be set and values for setting optional register.
Descriptions for each cell would be required here.
And isn't tuning-table closer to board portion rather than soc portion?
Quoted 132 lines
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt new file +63
-0+ +Optional properties: + +/* These registers from pctrl node used for tuning mmc controller if required */ +* clken-reg: should be clock enable register and offset bit +* drv-sel-reg: should be driver delay select register, start bit and bits numbers +* sam-sel-reg: should be sample delay select register, start bit and bits numbers +* div-reg: should be divider register, start bit and bits numbers + +Example: + + /* SoC portion */ + dwmmc_0: dwmmc0 at fcd03000 { + compatible = "hisilicon,hi4511-dw-mshc"; + reg = <0xfcd03000 0x1000>; + interrupts = <0 16 4>; + #address-cells = <1>; + #size-cells = <0>; + clocks = <&clk_sd>, <&clk_ddrc_per>; + clock-names = "ciu", "biu"; + clken-reg = <0x1f8 0>; + drv-sel-reg = <0x1f8 4 4>; + sam-sel-reg = <0x1f8 8 4>; + div-reg = <0x1f8 1 3>; + tuning-table = + <180000000 6 6 13 13 25000000>, + <0 0 0 0 0 0>, + <360000000 6 4 2 0 50000000>, + <180000000 6 4 13 13 25000000>, + <360000000 6 4 2 0 50000000>, + <720000000 6 1 9 4 100000000>, + <0 0 0 0 0 0>, + <360000000 7 1 3 0 50000000>; + }; + + /* Board portion */ + dwmmc0 at fcd03000 { + num-slots = <1>; + vmmc-supply = <&ldo12>; + fifo-depth = <0x100>; + supports-highspeed; + pinctrl-names = "default"; + pinctrl-0 = <&sd_pmx_pins &sd_cfg_func1 &sd_cfg_func2>; + slot at 0 { + reg = <0>; + bus-width = <4>; + disable-wp; + cd-gpios = <&gpio10 3 0>; + }; + }; + +PCTRL: Peripheral misc control register + +Required Properties: +- compatible: "hisilicon,pctrl" +- reg: Address and size of pctrl. + +Example: + + pctrl: pctrl at fca09000 { + compatible = "hisilicon,pctrl"; + reg = <0xfca09000 0x1000>; + };drivers/mmc/host/Kconfig +10
-0@@ -575,6 +575,16 @@ config MMC_DW_SOCFPGA This selects support for Altera SoCFPGA specific extensions to the Synopsys DesignWare Memory Card Interface driver. +config MMC_DW_K3 + tristate "K3 specific extensions for Synopsys DW Memory Card Interface" + depends on MMC_DW + select MMC_DW_PLTFM + select MMC_DW_IDMAC + help + This selects support for Hisilicon K3 SoC specific extensions to the + Synopsys DesignWare Memory Card Interface driver. Select this option + for platforms based on Hisilicon K3 SoC's. + config MMC_DW_PCI tristate "Synopsys Designware MCI support on PCI bus" depends on MMC_DW && PCIdrivers/mmc/host/Makefile +1
-0@@ -43,6 +43,7 @@ obj-$(CONFIG_MMC_DW) += dw_mmc.o obj-$(CONFIG_MMC_DW_PLTFM) += dw_mmc-pltfm.o obj-$(CONFIG_MMC_DW_EXYNOS) += dw_mmc-exynos.o obj-$(CONFIG_MMC_DW_SOCFPGA) += dw_mmc-socfpga.o +obj-$(CONFIG_MMC_DW_K3) += dw_mmc-k3.o obj-$(CONFIG_MMC_DW_PCI) += dw_mmc-pci.o obj-$(CONFIG_MMC_SH_MMCIF) += sh_mmcif.o obj-$(CONFIG_MMC_JZ4740) += jz4740_mmc.odrivers/mmc/host/dw_mmc-k3.c new file +30
-0@@ -0,0 +1,247 @@ +/* +* Copyright (c) 2013 Linaro Ltd. +* Copyright (c) 2013 Hisilicon Limited. +* +* 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; either version 2 of the License, or +* (at your option) any later version. +*/ + +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/clk.h> +#include <linux/mmc/host.h> +#include <linux/mmc/dw_mmc.h> +#include <linux/of_address.h> + +#include "dw_mmc.h" +#include "dw_mmc-pltfm.h" + +#define TABLE_WIDTH 6 +#define TABLE_HEIGHT 8 +struct dw_mci_k3_priv_data { +int old_timing; +u32 table[TABLE_WIDTH *TABLE_HEIGHT ]; +u32 clken_reg; +u32 clken_bit; +u32 sam_reg; +u32 sam_off; +u32 sam_bits;
drivers/mmc/host/dw_mmc-k3.c line 40
Quoted 10 lines
drivers/mmc/host/dw_mmc-k3.c new file +10
-0+u32 drv_reg; +u32 drv_off; +u32 drv_bits; +u32 div_reg; +u32 div_off; +u32 div_bits; +}; + +static void __iomem *pctrl; +static DEFINE_SPINLOCK (mmc_tuning_lock);
Can the above variables be involved in dw_mci_k3_priv_data instead of global declaration?
Quoted 46 lines
drivers/mmc/host/dw_mmc-k3.c new file +46
-0+ +static u32 dw_mci_k3_delay (u32 val,u32 para,u32 off,u32 len) +{ +u32 i; + +if (para >=0 ) { +for (i =0 ; i < len; i++) { +if (para %2 ) + val |=1 << (off + i); +else + val &= ~(1 << (off + i)); + para = para >>1 ; + } + } +return val; +} + +static void dw_mci_k3_set_timing (struct dw_mci_k3_priv_data *priv, +u32 sam,u32 drv,u32 div) +{ +u32 val; +unsigned long flags; + +if (!pctrl || !priv->clken_reg || !priv->sam_reg + || !priv->drv_reg || !priv->div_reg) +return ; + +spin_lock_irqsave (&mmc_tuning_lock, flags); + + val =readl (pctrl + priv->clken_reg); + val &= ~(1 << priv->clken_bit); +writel (val, pctrl + priv->clken_reg); + + val =readl (pctrl + priv->sam_reg); + val =dw_mci_k3_delay (val, sam, priv->sam_off, priv->sam_bits); +writel (val, pctrl + priv->sam_reg); + + val =readl (pctrl + priv->drv_reg); + val =dw_mci_k3_delay (val, drv, priv->drv_off, priv->drv_bits); +writel (val, pctrl + priv->drv_reg); + + val =readl (pctrl + priv->div_reg); + val =dw_mci_k3_delay (val, div, priv->div_off, priv->div_bits); +writel (val, pctrl + priv->div_reg); + + val =readl (pctrl + priv->clken_reg);
drivers/mmc/host/dw_mmc-k3.c line 96
Quoted 10 lines
drivers/mmc/host/dw_mmc-k3.c new file +10
-0+ val |=1 << priv->clken_bit; +writel (val, pctrl + priv->clken_reg); + +spin_unlock_irqrestore (&mmc_tuning_lock, flags); +} + +static void dw_mci_k3_tun (struct dw_mci *host,int timing) +{ +struct dw_mci_k3_priv_data *priv = host->priv; +u32 *table = &priv->table[TABLE_WIDTH * timing];
Timing value should be less than TABLE_HEIGHT.
It needs to check the range of value.
Quoted 14 lines
drivers/mmc/host/dw_mmc-k3.c new file +14
-0+int ret; + +if (priv->old_timing == timing) +return ; + + ret =clk_set_rate (host->ciu_clk, table[0 ]); +if (ret) { +dev_err (host->dev,"clk_set_rate failed\n" ); +return ; + } +dw_mci_k3_set_timing (priv, (table[3 ] + table[4 ]) /2 , + table[2 ], table[1 ]); + host->bus_hz = table[5 ]; + priv->old_timing = timing;
drivers/mmc/host/dw_mmc-k3.c line 120
Quoted 10 lines
drivers/mmc/host/dw_mmc-k3.c new file +10
-0+} + +static void dw_mci_k3_set_ios (struct dw_mci *host,struct mmc_ios *ios) +{ +dw_mci_k3_tun (host, ios->timing); +} + +static int dw_mci_k3_setup_clock (struct dw_mci *host) +{ +dw_mci_k3_tun (host,MMC_TIMING_LEGACY );
Is it necessary here?
When card-init, MMC_TIMING_LEGACY will be passed via dw_mci_k3_set_ios().
Quoted 46 lines
drivers/mmc/host/dw_mmc-k3.c new file +46
-0+return 0 ; +} + +static int dw_mci_k3_parse_dt (struct dw_mci *host) +{ +struct dw_mci_k3_priv_data *priv; +struct device_node *np = host->dev->of_node, *node; +u32 data[3 ]; +int ret; + + priv =devm_kzalloc (host->dev,sizeof (*priv),GFP_KERNEL ); +if (!priv) { +dev_err (host->dev,"mem alloc failed for private data\n" ); +return -ENOMEM ; + } + priv->old_timing =-1 ; + host->priv = priv; + + ret =of_property_read_u32_array (host->dev->of_node,"tuning-table" , + priv->table,TABLE_WIDTH *TABLE_HEIGHT ); +if (ret) { +dev_err (host->dev,"not found tuning-table\n" ); +return -EINVAL ; + } + +if (!pctrl) { + node =of_find_compatible_node (NULL ,NULL ,"hisilicon,pctrl" ); + pctrl =of_iomap (node,0 ); + } + + ret =of_property_read_u32_array (np,"clken-reg" , data,2 ); +if (!ret) { + priv->clken_reg = data[0 ]; + priv->clken_bit = data[1 ]; + } + + ret =of_property_read_u32_array (np,"drv-sel-reg" , data,3 ); +if (!ret) { + priv->drv_reg = data[0 ]; + priv->drv_off = data[1 ]; + priv->drv_bits = data[2 ]; + } + + ret =of_property_read_u32_array (np,"sam-sel-reg" , data,3 ); +if (!ret) { + priv->sam_reg = data[0 ];
drivers/mmc/host/dw_mmc-k3.c line 176
Quoted 10 lines
drivers/mmc/host/dw_mmc-k3.c new file +10
-0+ priv->sam_off = data[1 ]; + priv->sam_bits = data[2 ]; + } + + ret =of_property_read_u32_array (np,"div-reg" , data,3 ); +if (!ret) { + priv->div_reg = data[0 ]; + priv->div_off = data[1 ]; + priv->div_bits = data[2 ]; + }
All properties seem mandatory.
If right, it should return error in case of failure?
Quoted 40 lines
drivers/mmc/host/dw_mmc-k3.c new file +40
-0+ +return 0 ; +} + +static unsigned long k3_dwmmc_caps[4 ] = { +MMC_CAP_4_BIT_DATA |MMC_CAP_SD_HIGHSPEED , +MMC_CAP_8_BIT_DATA |MMC_CAP_MMC_HIGHSPEED , +0 , +0 , +}; + +static const struct dw_mci_drv_data k3_drv_data = { + .caps = k3_dwmmc_caps, + .set_ios = dw_mci_k3_set_ios, + .setup_clock = dw_mci_k3_setup_clock, + .parse_dt = dw_mci_k3_parse_dt, +}; + +static const struct of_device_id dw_mci_k3_match[] = { + { .compatible ="hisilicon,hi4511-dw-mshc" , + .data = &k3_drv_data, }, + {}, +}; +MODULE_DEVICE_TABLE (of, dw_mci_k3_match); + +static int dw_mci_k3_probe (struct platform_device *pdev) +{ +const struct dw_mci_drv_data *drv_data; +const struct of_device_id *match; + + match =of_match_node (dw_mci_k3_match, pdev->dev.of_node); + drv_data = match->data; + +return dw_mci_pltfm_register (pdev, drv_data); +} + +static int dw_mci_k3_suspend (struct device *dev) +{ +struct dw_mci *host =dev_get_drvdata (dev); +
drivers/mmc/host/dw_mmc-k3.c line 226
Quoted 10 lines
drivers/mmc/host/dw_mmc-k3.c new file +10
-0+return dw_mci_suspend (host); +} + +static int dw_mci_k3_resume (struct device *dev) +{ +struct dw_mci *host =dev_get_drvdata (dev); +struct dw_mci_k3_priv_data *priv = host->priv; + + priv->old_timing =-1 ; +dw_mci_k3_tun (host,MMC_TIMING_LEGACY );
Same above.
When resuming, MMC_TIMING_LEGACY will be passed via dw_mci_k3_set_ios().
Thanks,
Seungwon Jeon
Quoted 28 lines
drivers/mmc/host/dw_mmc-k3.c new file +21
-1+ +return dw_mci_resume (host); +} + +SIMPLE_DEV_PM_OPS (dw_mci_k3_pmops, dw_mci_k3_suspend, dw_mci_k3_resume); + +static struct platform_driver dw_mci_k3_pltfm_driver = { + .probe = dw_mci_k3_probe, + .remove = dw_mci_pltfm_remove, + .driver = { + .name ="dwmmc_k3" , + .of_match_table = dw_mci_k3_match, + .pm = &dw_mci_k3_pmops, + }, +}; + +module_platform_driver (dw_mci_k3_pltfm_driver); + +MODULE_DESCRIPTION ("K3 Specific DW-MSHC Driver Extension" ); +MODULE_LICENSE ("GPL v2" ); +MODULE_ALIAS ("platform:dwmmc-k3" ); --1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/2 mmc: dw_mmc: add dw_mmc-k3 for k3 platform
Dear Seungwon
Quoted 3 lines · Seungwon Jeon
Quoted 1 line
+static
DEFINE_SPINLOCK(mmc_tuning_lock);Can the above variables be involved in
dw_mci_k3_priv_datainstead of global declaration?
Unfortunately, this can be be put in priv_data, which is different instance for different controller.
Here need protect register shared by different controllers
Quoted 5 lines
drivers/mmc/host/dw_mmc-k3.c line 120
Quoted 3 lines
drivers/mmc/host/dw_mmc-k3.c new file +3
-0+static int dw_mci_k3_setup_clock (struct dw_mci *host) +{ +dw_mci_k3_tun (host,MMC_TIMING_LEGACY );Is it necessary here?
When card-init,MMC_TIMING_LEGACYwill be passed viadw_mci_k3_set_ios().
Read register will fail if not set these register earlier, and set_ios is too late.
Same reason for resume.
Thanks
PATCH 2/2 mmc: dw_mmc: add dw_mmc-k3 for k3 platform
In reply to Zhangfei GaoQuoted 25 lines · Zhangfei Gao
Add
dw_mmc-k3.cfor k3v2, support sd/emmcSigned-off-by Zhangfei Gao <[email protected]>Tested-by Zhigang Wang <[email protected]>--- .../devicetree/bindings/mmc/k3-dw-mshc.txt | 83 +++++++ drivers/mmc/host/Kconfig | 10 + drivers/mmc/host/Makefile | 1 + drivers/mmc/host/dw_mmc-k3.c | 247 ++++++++++++++++++++ 4 files changed, 341 insertions(+) create mode 100644 Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt create mode 100644 drivers/mmc/host/dw_mmc-k3.cDocumentation/devicetree/bindings/mmc/k3-dw-mshc.txt new file +6
-0@@ -0,0 +1,83 @@ +* Hisilicon specific extensions to the Synopsys Designware Mobile + Storage Host Controller + +Read synopsis-dw-mshc.txt for more details +The Synopsys designware mobile storage host controller is used to interface +a SoC with storage medium such as eMMC or SD/MMC cards. This file documents
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt line 16
Quoted 10 lines
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt new file +10
-0+differences between the core Synopsys dw mshc controller properties described +by synopsis-dw-mshc.txt and the properties used by the Hisilicon specific +extensions to the Synopsys Designware Mobile Storage Host Controller. + +Required Properties: + +* compatible: should be + - "hisilicon,hi4511-dw-mshc": for controllers with hi4511 + specific extentions. +* reg: should be address and size of mmc controller
This should be covered by the base binding.
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt line 20
Quoted 4 lines
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt new file +4
-0+* vmmc-supply: should be vmmc used in dwmmc +* fifo-depth: should be provided if register can not provide correct value +* tuning-table: should be array to tune mmc controller, including clock rate + to be set and values for setting optional register.
Please define the size and what the values mean.
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt line 28
Quoted 8 lines
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt new file +8
-0+ +Optional properties: + +/* These registers from pctrl node used for tuning mmc controller if required */ +* clken-reg: should be clock enable register and offset bit +* drv-sel-reg: should be driver delay select register, start bit and bits numbers +* sam-sel-reg: should be sample delay select register, start bit and bits numbers +* div-reg: should be divider register, start bit and bits numbers
Do these really vary on different boards or versions of the IP? If not, then put this information in the kernel.
Otherwise, these need better description such as number of words and order of values.
Quoted 23 lines
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt new file +23
-0+ +Example: + + /* SoC portion */ + dwmmc_0: dwmmc0 at fcd03000 { + compatible = "hisilicon,hi4511-dw-mshc"; + reg = <0xfcd03000 0x1000>; + interrupts = <0 16 4>; + #address-cells = <1>; + #size-cells = <0>; + clocks = <&clk_sd>, <&clk_ddrc_per>; + clock-names = "ciu", "biu"; + clken-reg = <0x1f8 0>; + drv-sel-reg = <0x1f8 4 4>; + sam-sel-reg = <0x1f8 8 4>; + div-reg = <0x1f8 1 3>; + tuning-table = + <180000000 6 6 13 13 25000000>, + <0 0 0 0 0 0>, + <360000000 6 4 2 0 50000000>, + <180000000 6 4 13 13 25000000>, + <360000000 6 4 2 0 50000000>, + <720000000 6 1 9 4 100000000>,
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt line 61
Quoted 10 lines
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt new file +10
-0+ <0 0 0 0 0 0>, + <360000000 7 1 3 0 50000000>; + }; + + /* Board portion */ + dwmmc0 at fcd03000 { + num-slots = <1>; + vmmc-supply = <&ldo12>; + fifo-depth = <0x100>; + supports-highspeed;
Please reference that the binding uses standard SD properties (state which binding document).
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt line 72
Quoted 11 lines
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt new file +11
-0+ pinctrl-names = "default"; + pinctrl-0 = <&sd_pmx_pins &sd_cfg_func1 &sd_cfg_func2>; + slot at 0 { + reg = <0>; + bus-width = <4>; + disable-wp; + cd-gpios = <&gpio10 3 0>; + }; + }; + +PCTRL: Peripheral misc control register
Is this only MMC control bits? Seems like this belongs in its own doc.
Quoted 305 lines
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt new file +11
-0+ +Required Properties: +- compatible: "hisilicon,pctrl" +- reg: Address and size of pctrl. + +Example: + + pctrl: pctrl at fca09000 { + compatible = "hisilicon,pctrl"; + reg = <0xfca09000 0x1000>; + };drivers/mmc/host/Kconfig +10
-0@@ -575,6 +575,16 @@ config MMC_DW_SOCFPGA This selects support for Altera SoCFPGA specific extensions to the Synopsys DesignWare Memory Card Interface driver. +config MMC_DW_K3 + tristate "K3 specific extensions for Synopsys DW Memory Card Interface" + depends on MMC_DW + select MMC_DW_PLTFM + select MMC_DW_IDMAC + help + This selects support for Hisilicon K3 SoC specific extensions to the + Synopsys DesignWare Memory Card Interface driver. Select this option + for platforms based on Hisilicon K3 SoC's. + config MMC_DW_PCI tristate "Synopsys Designware MCI support on PCI bus" depends on MMC_DW && PCIdrivers/mmc/host/Makefile +1
-0@@ -43,6 +43,7 @@ obj-$(CONFIG_MMC_DW) += dw_mmc.o obj-$(CONFIG_MMC_DW_PLTFM) += dw_mmc-pltfm.o obj-$(CONFIG_MMC_DW_EXYNOS) += dw_mmc-exynos.o obj-$(CONFIG_MMC_DW_SOCFPGA) += dw_mmc-socfpga.o +obj-$(CONFIG_MMC_DW_K3) += dw_mmc-k3.o obj-$(CONFIG_MMC_DW_PCI) += dw_mmc-pci.o obj-$(CONFIG_MMC_SH_MMCIF) += sh_mmcif.o obj-$(CONFIG_MMC_JZ4740) += jz4740_mmc.odrivers/mmc/host/dw_mmc-k3.c new file +247
-1@@ -0,0 +1,247 @@ +/* +* Copyright (c) 2013 Linaro Ltd. +* Copyright (c) 2013 Hisilicon Limited. +* +* 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; either version 2 of the License, or +* (at your option) any later version. +*/ + +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/clk.h> +#include <linux/mmc/host.h> +#include <linux/mmc/dw_mmc.h> +#include <linux/of_address.h> + +#include "dw_mmc.h" +#include "dw_mmc-pltfm.h" + +#define TABLE_WIDTH 6 +#define TABLE_HEIGHT 8 +struct dw_mci_k3_priv_data { +int old_timing; +u32 table[TABLE_WIDTH *TABLE_HEIGHT ]; +u32 clken_reg; +u32 clken_bit; +u32 sam_reg; +u32 sam_off; +u32 sam_bits; +u32 drv_reg; +u32 drv_off; +u32 drv_bits; +u32 div_reg; +u32 div_off; +u32 div_bits; +}; + +static void __iomem *pctrl; +static DEFINE_SPINLOCK (mmc_tuning_lock); + +static u32 dw_mci_k3_delay (u32 val,u32 para,u32 off,u32 len) +{ +u32 i; + +if (para >=0 ) { +for (i =0 ; i < len; i++) { +if (para %2 ) + val |=1 << (off + i); +else + val &= ~(1 << (off + i)); + para = para >>1 ; + } + } +return val; +} + +static void dw_mci_k3_set_timing (struct dw_mci_k3_priv_data *priv, +u32 sam,u32 drv,u32 div) +{ +u32 val; +unsigned long flags; + +if (!pctrl || !priv->clken_reg || !priv->sam_reg + || !priv->drv_reg || !priv->div_reg) +return ; + +spin_lock_irqsave (&mmc_tuning_lock, flags); + + val =readl (pctrl + priv->clken_reg); + val &= ~(1 << priv->clken_bit); +writel (val, pctrl + priv->clken_reg); + + val =readl (pctrl + priv->sam_reg); + val =dw_mci_k3_delay (val, sam, priv->sam_off, priv->sam_bits); +writel (val, pctrl + priv->sam_reg); + + val =readl (pctrl + priv->drv_reg); + val =dw_mci_k3_delay (val, drv, priv->drv_off, priv->drv_bits); +writel (val, pctrl + priv->drv_reg); + + val =readl (pctrl + priv->div_reg); + val =dw_mci_k3_delay (val, div, priv->div_off, priv->div_bits); +writel (val, pctrl + priv->div_reg); + + val =readl (pctrl + priv->clken_reg); + val |=1 << priv->clken_bit; +writel (val, pctrl + priv->clken_reg); + +spin_unlock_irqrestore (&mmc_tuning_lock, flags); +} + +static void dw_mci_k3_tun (struct dw_mci *host,int timing) +{ +struct dw_mci_k3_priv_data *priv = host->priv; +u32 *table = &priv->table[TABLE_WIDTH * timing]; +int ret; + +if (priv->old_timing == timing) +return ; + + ret =clk_set_rate (host->ciu_clk, table[0 ]); +if (ret) { +dev_err (host->dev,"clk_set_rate failed\n" ); +return ; + } +dw_mci_k3_set_timing (priv, (table[3 ] + table[4 ]) /2 , + table[2 ], table[1 ]); + host->bus_hz = table[5 ]; + priv->old_timing = timing; +} + +static void dw_mci_k3_set_ios (struct dw_mci *host,struct mmc_ios *ios) +{ +dw_mci_k3_tun (host, ios->timing); +} + +static int dw_mci_k3_setup_clock (struct dw_mci *host) +{ +dw_mci_k3_tun (host,MMC_TIMING_LEGACY ); +return 0 ; +} + +static int dw_mci_k3_parse_dt (struct dw_mci *host) +{ +struct dw_mci_k3_priv_data *priv; +struct device_node *np = host->dev->of_node, *node; +u32 data[3 ]; +int ret; + + priv =devm_kzalloc (host->dev,sizeof (*priv),GFP_KERNEL ); +if (!priv) { +dev_err (host->dev,"mem alloc failed for private data\n" ); +return -ENOMEM ; + } + priv->old_timing =-1 ; + host->priv = priv; + + ret =of_property_read_u32_array (host->dev->of_node,"tuning-table" , + priv->table,TABLE_WIDTH *TABLE_HEIGHT ); +if (ret) { +dev_err (host->dev,"not found tuning-table\n" ); +return -EINVAL ; + } + +if (!pctrl) { + node =of_find_compatible_node (NULL ,NULL ,"hisilicon,pctrl" ); + pctrl =of_iomap (node,0 ); + } + + ret =of_property_read_u32_array (np,"clken-reg" , data,2 ); +if (!ret) { + priv->clken_reg = data[0 ]; + priv->clken_bit = data[1 ]; + } + + ret =of_property_read_u32_array (np,"drv-sel-reg" , data,3 ); +if (!ret) { + priv->drv_reg = data[0 ]; + priv->drv_off = data[1 ]; + priv->drv_bits = data[2 ]; + } + + ret =of_property_read_u32_array (np,"sam-sel-reg" , data,3 ); +if (!ret) { + priv->sam_reg = data[0 ]; + priv->sam_off = data[1 ]; + priv->sam_bits = data[2 ]; + } + + ret =of_property_read_u32_array (np,"div-reg" , data,3 ); +if (!ret) { + priv->div_reg = data[0 ]; + priv->div_off = data[1 ]; + priv->div_bits = data[2 ]; + } + +return 0 ; +} + +static unsigned long k3_dwmmc_caps[4 ] = { +MMC_CAP_4_BIT_DATA |MMC_CAP_SD_HIGHSPEED , +MMC_CAP_8_BIT_DATA |MMC_CAP_MMC_HIGHSPEED , +0 , +0 , +}; + +static const struct dw_mci_drv_data k3_drv_data = { + .caps = k3_dwmmc_caps, + .set_ios = dw_mci_k3_set_ios, + .setup_clock = dw_mci_k3_setup_clock, + .parse_dt = dw_mci_k3_parse_dt, +}; + +static const struct of_device_id dw_mci_k3_match[] = { + { .compatible ="hisilicon,hi4511-dw-mshc" , + .data = &k3_drv_data, }, + {}, +}; +MODULE_DEVICE_TABLE (of, dw_mci_k3_match); + +static int dw_mci_k3_probe (struct platform_device *pdev) +{ +const struct dw_mci_drv_data *drv_data; +const struct of_device_id *match; + + match =of_match_node (dw_mci_k3_match, pdev->dev.of_node); + drv_data = match->data; + +return dw_mci_pltfm_register (pdev, drv_data); +} + +static int dw_mci_k3_suspend (struct device *dev) +{ +struct dw_mci *host =dev_get_drvdata (dev); + +return dw_mci_suspend (host); +} + +static int dw_mci_k3_resume (struct device *dev) +{ +struct dw_mci *host =dev_get_drvdata (dev); +struct dw_mci_k3_priv_data *priv = host->priv; + + priv->old_timing =-1 ; +dw_mci_k3_tun (host,MMC_TIMING_LEGACY ); + +return dw_mci_resume (host); +} + +SIMPLE_DEV_PM_OPS (dw_mci_k3_pmops, dw_mci_k3_suspend, dw_mci_k3_resume); + +static struct platform_driver dw_mci_k3_pltfm_driver = { + .probe = dw_mci_k3_probe, + .remove = dw_mci_pltfm_remove, + .driver = { + .name ="dwmmc_k3" , + .of_match_table = dw_mci_k3_match, + .pm = &dw_mci_k3_pmops, + }, +}; + +module_platform_driver (dw_mci_k3_pltfm_driver); + +MODULE_DESCRIPTION ("K3 Specific DW-MSHC Driver Extension" ); +MODULE_LICENSE ("GPL v2" ); +MODULE_ALIAS ("platform:dwmmc-k3" ); --1.7.9.5
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 2/2 mmc: dw_mmc: add dw_mmc-k3 for k3 platform
Dear Rob
Quoted 14 lines · Rob Herring
Quoted 12 lines · Zhangfei Gao
+++
b/Documentation/devicetree/bindings/mmc/k3-dw-mshc.txtDocumentation/devicetree/bindings/mmc/k3-dw-mshc.txt new file +10
-0@@ -0,0 +1,83 @@ +* Hisilicon specific extensions to the Synopsys Designware Mobile + Storage Host Controller + +Read synopsis-dw-mshc.txt for more details +The Synopsys designware mobile storage host controller is used to interface +a SoC with storage medium such as eMMC or SD/MMC cards. This file documents +differences between the core Synopsys dw mshc controller properties described +by synopsis-dw-mshc.txt and the properties used by the Hisilicon specific +extensions to the Synopsys Designware Mobile Storage Host Controller. +
Quoted 8 lines
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt line 16
Quoted 6 lines
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt new file +6
-0+Required Properties: + +* compatible: should be + - "hisilicon,hi4511-dw-mshc": for controllers with hi4511 + specific extentions. +* reg: should be address and size of mmc controllerThis should be covered by the base binding.
Yes, got it.
Quoted 20 lines
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt line 20
Quoted 5 lines
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt new file +4
-0+* vmmc-supply: should be vmmc used in dwmmc +* fifo-depth: should be provided if register can not provide correct value +* tuning-table: should be array to tune mmc controller, including clock rate + to be set and values for setting optional register.Please define the size and what the values mean.
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt line 28
Quoted 8 lines
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt new file +8
-0+ +Optional properties: + +/* These registers from pctrl node used for tuning mmc controller if required */ +* clken-reg: should be clock enable register and offset bit +* drv-sel-reg: should be driver delay select register, start bit and bits numbers +* sam-sel-reg: should be sample delay select register, start bit and bits numbers +* div-reg: should be divider register, start bit and bits numbersDo these really vary on different boards or versions of the IP? If not, then put this information in the kernel.
Quoted 2 lines
Otherwise, these need better description such as number of words and order of values.
Double checked these registers are not used in newer version. Will follow Arnd's suggestion to abstract in clock.
Quoted 10 lines
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt line 61
Quoted 7 lines
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt new file +7
-0+ + /* Board portion */ + dwmmc0 at fcd03000 { + num-slots = <1>; + vmmc-supply = <&ldo12>; + fifo-depth = <0x100>; + supports-highspeed;Please reference that the binding uses standard SD properties (state which binding document).
Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt is used for base doc describing supports-highspeed.
Quoted 14 lines
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt line 72
Quoted 12 lines
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt new file +11
-0+ pinctrl-names = "default"; + pinctrl-0 = <&sd_pmx_pins &sd_cfg_func1 &sd_cfg_func2>; + slot at 0 { + reg = <0>; + bus-width = <4>; + disable-wp; + cd-gpios = <&gpio10 3 0>; + }; + }; + +PCTRL: Peripheral misc control registerIs this only MMC control bits? Seems like this belongs in its own doc.
OK, will move out.
Thanks
PATCH 2/2 mmc: dw_mmc: add dw_mmc-k3 for k3 platform
In reply to Zhangfei GaoQuoted 4 lines · Zhangfei Gao
Add
dw_mmc-k3.cfor k3v2, support sd/emmcSigned-off-by Zhangfei Gao <[email protected]>Tested-by Zhigang Wang <[email protected]>
We are currently having the exact same discussion problem on the altera version of dw_mmc: It seems that all this driver does in addition to the common code is to have a custom way to set up the card clocks.
In both cases, there is a custom piece of IP logic providing this clock (here it is in the "hisilicon,pctrl" node). IMHO that should be a proper clock driver so you can use the existing call to clk_set_rate to set it up and not need a special platform driver at all.
Arnd
PATCH 2/2 mmc: dw_mmc: add dw_mmc-k3 for k3 platform
Dear Arnd
Quoted 6 lines · Arnd Bergmann
Quoted 4 lines · Zhangfei Gao
Add
dw_mmc-k3.cfor k3v2, support sd/emmcSigned-off-by Zhangfei Gao <[email protected]>Tested-by Zhigang Wang <[email protected]>
Quoted 9 lines
We are currently having the exact same discussion problem on the altera version of
dw_mmc: It seems that all this driver does in addition to the common code is to have a custom way to set up the card clocks.In both cases, there is a custom piece of IP logic providing this clock (here it is in the "hisilicon,pctrl" node). IMHO that should be a proper clock driver so you can use the existing call to
clk_set_rateto set it up and not need a special platform driver at all.
Thanks for the good suggestion, it can be abstracted to clock.
The issue for this version's ip is there are some registers need to be set, including fixed factor and phase, which may be required to be tuned, however it can be hide in clock.
Double checked next version's ip, it is more intelligent and only fixed factor is required, more like a clock, and all these register accessing are NOT required.
Will update new version to abstract these chip depended registers to clock.
Thanks
PATCH 2/2 mmc: dw_mmc: add dw_mmc-k3 for k3 platform
Quoted 11 lines · Zhangfei Gao
Thanks for the good suggestion, it can be abstracted to clock.
The issue for this version's ip is there are some registers need to be set, including fixed factor and phase, which may be required to be tuned, however it can be hide in clock.
Double checked next version's ip, it is more intelligent and only fixed factor is required, more like a clock, and all these register accessing are NOT required.
Will update new version to abstract these chip depended registers to clock.
Ok, please stay in contact with Dinh Nguyen over this, since his side is work-in-progress and we are still evaluating how to best encode the phase setting in DT in a generic form.
Arnd
PATCH 2/2 mmc: dw_mmc: add dw_mmc-k3 for k3 platform
Quoted 11 lines · Arnd Bergmann
Quoted 10 lines · Zhangfei Gao
Thanks for the good suggestion, it can be abstracted to clock.
The issue for this version's ip is there are some registers need to be set, including fixed factor and phase, which may be required to be tuned, however it can be hide in clock.
Double checked next version's ip, it is more intelligent and only fixed factor is required, more like a clock, and all these register accessing are NOT required.
Quoted 5 lines
Quoted 1 line
Will update new version to abstract these chip depended registers to clock.
Ok, please stay in contact with Dinh Nguyen over this, since his side is work-in-progress and we are still evaluating how to best encode the phase setting in DT in a generic form.
Will the bindings "samsung,dw-mshc-sdr-timing" and "samsung,dw-mshc-ddr-timing" also work for the k3 platform as well? I think they should work, but just wanted to verify.
Heiko, on the rockchip platform, can you check to see if you have these cclk_in_drv and cclk_sample settings for the phase shift of the clocks? The SD/MMC IP version(2.40a) on Rockchip is the same version that is on SOCFPGA, so I think these settings are there. They can be located in some other "system" register block like SOCFPGA. The possible reason that you have not need to set them in the Rockchip code could be that the bootloader/firmware has already set them if you are booting from the SD/MMC source. You may need to set the clock phase settings if you boot from a non-SD source.
I think the reading of the "samsung,dw-mshc-ddr-timing" and "samsung,dw-msh-sdr-timing" bindings can also be moved into the generic dw_mmc driver if the above 2 conditions are correct.
Thanks,
Din
Quoted 3 lines
Arnd
PATCH 2/2 mmc: dw_mmc: add dw_mmc-k3 for k3 platform
Am Mittwoch, 11. Dezember 2013, 19:48:10 schrieb Dinh Nguyen:
Quoted 33 lines · Arnd Bergmann
Quoted 11 lines · Zhangfei Gao
Quoted 10 lines
Thanks for the good suggestion, it can be abstracted to clock.
The issue for this version's ip is there are some registers need to be set, including fixed factor and phase, which may be required to be tuned, however it can be hide in clock.
Double checked next version's ip, it is more intelligent and only fixed factor is required, more like a clock, and all these register accessing are NOT required.
Quoted 6 lines
Quoted 2 lines
Will update new version to abstract these chip depended registers to clock.
Ok, please stay in contact with Dinh Nguyen over this, since his side is work-in-progress and we are still evaluating how to best encode the phase setting in DT in a generic form.
Will the bindings "samsung,dw-mshc-sdr-timing" and "samsung,dw-mshc-ddr-timing" also work for the k3 platform as well? I think they should work, but just wanted to verify.
Heiko, on the rockchip platform, can you check to see if you have these
cclk_in_drvandcclk_samplesettings for the phase shift of the clocks? The SD/MMC IP version(2.40a) on Rockchip is the same version that is on SOCFPGA, so I think these settings are there. They can be located in some other "system" register block like SOCFPGA. The possible reason that you have not need to set them in the Rockchip code could be that the bootloader/firmware has already set them if you are booting from the SD/MMC source. You may need to set the clock phase settings if you boot from a non-SD source.
Quoted 3 lines
I think the reading of the "samsung,dw-mshc-ddr-timing" and "samsung,dw-msh-sdr-timing" bindings can also be moved into the generic
dw_mmcdriver if the above 2 conditions are correct.
The mmc-controller part of the rk-manual that is flying around the net, mentions these cclk_in_drv and cclk_in_sample as coming from somewhere, but sadly never where to get/set/access them.
The doc of the USE_HOLD_REG bit also mention the required settings of these cclk_in_* but nowhere is a word about the where to be found.
And the manual is notable for lacking all information related to the clock controller. And I also wasn't able to find any other indication where this might be set.
Heiko