ARM: sunxi: Add driver for SD/MMC hosts found on allwinner sunxi SOCs
Subsystems (5)
v4 cover ARM: sunxi: Add driver for SD/MMC hosts found on allwinner sunxi SOCs
Hello
The following patchset adds support for the SD/MMC host found in the Allwinner SoCs. It contains all the necessary modifications for clock environment and also the device tree script modification which add it to all the boards using it.
The clock environment function needed for phase offset configuration has been proposed and implemented by Emilio.
A lot of work and cleanup has been done by Hans de Goede. Special thanks to him! This patchset is the 4th attempt to send this driver upstream.
Changes since v1:
-Using mmc_of_parse instead of diy dt parsing -Adding nodes for all mmc controller to the dtsi files,
including sofar unused controllers
-Using generic GPIO slot library for WP/CD -Adding additional MMC device nodes into DTSI files
Changes since v2:
-Add missing Signed-off-by tags
-Stop using __raw_readl / __raw_writel so that barriers are properly used -Adding missing new lines
-Adding missing patch for automatic reparenting of clocks
Changes since v3:
-Move clk_enable / disable into host_init / exit (Hans) -Fix hang on boot caused by irq storm (Hans)
regards
David
---
David Lanzend?rfer (4):
ARM: sunxi: Add driver for SD/MMC hosts found on Allwinner sunxi SoCs
ARM: dts: sun7i: Add support for mmc
ARM: dts: sun4i: Add support for mmc
ARM: dts: sun5i: Add support for mmc
Emilio L?pez (2):
clk: sunxi: factors: automatic reparenting support
clk: sunxi: Implement MMC phase control
Hans de Goede (1):
ARM: sunxi: clk: export clk_sunxi_mmc_phase_control
arch/arm/boot/dts/sun4i-a10-a1000.dts | 8 arch/arm/boot/dts/sun4i-a10-cubieboard.dts | 8 arch/arm/boot/dts/sun4i-a10.dtsi | 54 + arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dts | 30 + arch/arm/boot/dts/sun5i-a10s.dtsi | 44 + arch/arm/boot/dts/sun5i-a13-olinuxino-micro.dts | 15 arch/arm/boot/dts/sun5i-a13-olinuxino.dts | 15 arch/arm/boot/dts/sun5i-a13.dtsi | 37 + arch/arm/boot/dts/sun7i-a20-cubieboard2.dts | 8 arch/arm/boot/dts/sun7i-a20-cubietruck.dts | 8 arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts | 23 + arch/arm/boot/dts/sun7i-a20.dtsi | 61 ++ drivers/clk/sunxi/clk-factors.c | 36 + drivers/clk/sunxi/clk-sunxi.c | 35 + drivers/mmc/host/Kconfig | 7 drivers/mmc/host/Makefile | 2 drivers/mmc/host/sunxi-mci.c | 871 ++++++++++++++++++++++ drivers/mmc/host/sunxi-mci.h | 239 ++++++ include/linux/clk/sunxi.h | 22 + 19 files changed, 1523 insertions(+) create mode 100644 drivers/mmc/host/sunxi-mci.c create mode 100644 drivers/mmc/host/sunxi-mci.h create mode 100644 include/linux/clk/sunxi.h
Signature · 1 line
Signature
PATCH v4 1/7 clk: sunxi: factors: automatic reparenting support
From: Emilio L?pez <[email protected]>
This commit implements .determine_rate, so that our factor clocks can be reparented when needed.
--- drivers/clk/sunxi/clk-factors.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
drivers/clk/sunxi/clk-factors.c +36 -0
@@ -77,6 +77,41 @@ static long clk_factors_round_rate(struct clk_hw *hw, unsigned long rate,return rate; } +static long clk_factors_determine_rate (struct clk_hw *hw,unsigned long rate, +unsigned long *best_parent_rate, +struct clk **best_parent_p) +{ +struct clk *clk = hw->clk, *parent, *best_parent =NULL ; +int i, num_parents; +unsigned long parent_rate, best =0 , child_rate, best_child_rate =0 ; + +/* find the parent that can help provide the fastest rate <= rate */ + num_parents =__clk_get_num_parents (clk); +for (i =0 ; i < num_parents; i++) { + parent =clk_get_parent_by_index (clk, i); +if (!parent) +continue ; +if (__clk_get_flags (clk) &CLK_SET_RATE_PARENT ) + parent_rate =__clk_round_rate (parent, rate); +else + parent_rate =__clk_get_rate (parent); + + child_rate =clk_factors_round_rate (hw, rate, &parent_rate); + +if (child_rate <= rate && child_rate > best_child_rate) { + best_parent = parent; + best = parent_rate; + best_child_rate = child_rate; + } + } + +if (best_parent) + *best_parent_p = best_parent; + *best_parent_rate = best; + +return best_child_rate; +} +static int clk_factors_set_rate (struct clk_hw *hw,unsigned long rate,unsigned long parent_rate) {
@@ -113,6 +148,7 @@ static int clk_factors_set_rate(struct clk_hw *hw, unsigned long rate, }const struct clk_ops clk_factors_ops = { + .determine_rate = clk_factors_determine_rate, .recalc_rate = clk_factors_recalc_rate, .round_rate = clk_factors_round_rate, .set_rate = clk_factors_set_rate,
PATCH v4 2/7 clk: sunxi: Implement MMC phase control
In reply to David LanzendörferFrom: Emilio L?pez <[email protected]>
--- drivers/clk/sunxi/clk-sunxi.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
drivers/clk/sunxi/clk-sunxi.c +35 -0
@@ -377,6 +377,41 @@ static void sun7i_a20_get_out_factors(u32 *freq, u32 parent_rate,/** +* clk_sunxi_mmc_phase_control() - configures MMC clock phase control +*/ + +void clk_sunxi_mmc_phase_control (struct clk_hw *hw,u8 sample,u8 output) +{ +#define to_clk_composite (_hw) container_of(_hw, struct clk_composite, hw) +#define to_clk_factors (_hw) container_of(_hw, struct clk_factors, hw) + +struct clk_composite *composite =to_clk_composite (hw); +struct clk_hw *rate_hw = composite->rate_hw; +struct clk_factors *factors =to_clk_factors (rate_hw); +unsigned long flags =0 ; +u32 reg; + +if (factors->lock) +spin_lock_irqsave (factors->lock, flags); + + reg =readl (factors->reg); + +/* set sample clock phase control */ + reg &= ~(0x7 <<20 ); + reg |= ((sample &0x7 ) <<20 ); + +/* set output clock phase control */ + reg &= ~(0x7 <<8 ); + reg |= ((output &0x7 ) <<8 ); + +writel (reg, factors->reg); + +if (factors->lock) +spin_unlock_irqrestore (factors->lock, flags); +} + + +/** * sunxi_factors_clk_setup() - Setup function for factor clocks */
PATCH v4 3/7 ARM: sunxi: clk: export clk_sunxi_mmc_phase_control
In reply to David LanzendörferFrom: Hans de Goede <[email protected]>
--- include/linux/clk/sunxi.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 include/linux/clk/sunxi.h
include/linux/clk/sunxi.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* Copyright 2013 - Hans de Goede <[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; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef __LINUX_CLK_SUNXI_H_ +#define __LINUX_CLK_SUNXI_H_ + +#include <linux/clk.h> + +void clk_sunxi_mmc_phase_control (struct clk_hw *hw,u8 sample,u8 output); + +#endif
PATCH v4 4/7 ARM: sunxi: Add driver for SD/MMC hosts found on Allwinner sunxi SoCs
In reply to David LanzendörferThis is based on the driver Allwinner ships in their Android kernel sources.
Initial porting to upstream kernels done by David Lanzend??rfer, additional fixes and cleanups by Hans de Goede.
It uses dma in bus-master mode using a built-in designware idmac controller, which is identical to the one found in the mmc-dw hosts.
The rest of the host is not identical to mmc-dw.
--- drivers/mmc/host/Kconfig | 7 drivers/mmc/host/Makefile | 2 drivers/mmc/host/sunxi-mci.c | 871 ++++++++++++++++++++++++++++++++++++++++++ drivers/mmc/host/sunxi-mci.h | 239 ++++++++++++ 4 files changed, 1119 insertions(+) create mode 100644 drivers/mmc/host/sunxi-mci.c create mode 100644 drivers/mmc/host/sunxi-mci.h
drivers/mmc/host/Kconfig +7 -0
@@ -689,3 +689,10 @@ config MMC_REALTEK_PCI help Say Y here to include driver code to support SD/MMC card interface of Realtek PCI-E card reader + +config MMC_SUNXI + tristate "Allwinner sunxi SD/MMC Host Controller support" + depends on ARCH_SUNXI + help + This selects support for the SD/MMC Host Controller on + Allwinner sunxi SoCs.
drivers/mmc/host/Makefile +2 -0
@@ -54,6 +54,8 @@ obj-$(CONFIG_MMC_WMT) += wmt-sdmmc.o obj-$(CONFIG_MMC_REALTEK_PCI) += rtsx_pci_sdmmc.o +obj-$(CONFIG_MMC_SUNXI) += sunxi-mci.o + obj-$(CONFIG_MMC_SDHCI_PLTFM) += sdhci-pltfm.o obj-$(CONFIG_MMC_SDHCI_CNS3XXX) += sdhci-cns3xxx.o obj-$(CONFIG_MMC_SDHCI_ESDHC_IMX) += sdhci-esdhc-imx.o
drivers/mmc/host/sunxi-mci.c new file +871 -0
871 lines not on this page · raw message
drivers/mmc/host/sunxi-mci.h new file +239 -0
239 lines not on this page · raw message
PATCH v4 5/7 ARM: dts: sun7i: Add support for mmc
In reply to David Lanzendörfer--- arch/arm/boot/dts/sun7i-a20-cubieboard2.dts | 8 +++ arch/arm/boot/dts/sun7i-a20-cubietruck.dts | 8 +++ arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts | 23 +++++++++ arch/arm/boot/dts/sun7i-a20.dtsi | 61 +++++++++++++++++++++++ 4 files changed, 100 insertions(+)
arch/arm/boot/dts/sun7i-a20-cubieboard2.dts +8 -0
@@ -34,6 +34,14 @@ }; }; + mmc0: mmc at 01c0f000 { + pinctrl-names = "default", "default"; + pinctrl-0 = <&mmc0_pins_a>; + pinctrl-1 = <&mmc0_cd_pin_reference_design>; + cd-gpios = <&pio 7 1 0>; /* PH1 */ + status = "okay"; + }; + pinctrl at 01c20800 { led_pins_cubieboard2: led_pins at 0 { allwinner,pins = "PH20", "PH21";
arch/arm/boot/dts/sun7i-a20-cubietruck.dts +8 -0
@@ -19,6 +19,14 @@ compatible = "cubietech,cubietruck", "allwinner,sun7i-a20"; soc at 01c00000 { + mmc0: mmc at 01c0f000 { + pinctrl-names = "default", "default"; + pinctrl-0 = <&mmc0_pins_a>; + pinctrl-1 = <&mmc0_cd_pin_reference_design>; + cd-gpios = <&pio 7 1 0>; /* PH1 */ + status = "okay"; + }; + pinctrl at 01c20800 { led_pins_cubietruck: led_pins at 0 { allwinner,pins = "PH7", "PH11", "PH20", "PH21";
arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts +23 -0
@@ -34,7 +34,30 @@ }; }; + mmc0: mmc at 01c0f000 { + pinctrl-names = "default", "default"; + pinctrl-0 = <&mmc0_pins_a>; + pinctrl-1 = <&mmc0_cd_pin_reference_design>; + cd-gpios = <&pio 7 1 0>; /* PH1 */ + status = "okay"; + }; + + mmc3: mmc at 01c12000 { + pinctrl-names = "default", "default"; + pinctrl-0 = <&mmc3_pins_a>; + pinctrl-1 = <&mmc3_cd_pin_olinuxinom>; + cd-gpios = <&pio 7 11 0>; /* PH11 */ + status = "okay"; + }; + pinctrl at 01c20800 { + mmc3_cd_pin_olinuxinom: mmc3_cd_pin at 0 { + allwinner,pins = "PH11"; + allwinner,function = "gpio_in"; + allwinner,drive = <0>; + allwinner,pull = <0>; + }; + led_pins_olinuxino: led_pins at 0 { allwinner,pins = "PH2"; allwinner,function = "gpio_out";
arch/arm/boot/dts/sun7i-a20.dtsi +61 -0
73 lines not on this page · raw message
PATCH v4 6/7 ARM: dts: sun4i: Add support for mmc
In reply to David Lanzendörfer--- arch/arm/boot/dts/sun4i-a10-a1000.dts | 8 ++++ arch/arm/boot/dts/sun4i-a10-cubieboard.dts | 8 ++++ arch/arm/boot/dts/sun4i-a10.dtsi | 54 ++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+)
arch/arm/boot/dts/sun4i-a10-a1000.dts +8 -0
@@ -35,6 +35,14 @@ }; }; + mmc0: mmc at 01c0f000 { + pinctrl-names = "default", "default"; + pinctrl-0 = <&mmc0_pins_a>; + pinctrl-1 = <&mmc0_cd_pin_reference_design>; + cd-gpios = <&pio 7 1 0>; /* PH1 */ + status = "okay"; + }; + pinctrl at 01c20800 { emac_power_pin_a1000: emac_power_pin at 0 { allwinner,pins = "PH15";
arch/arm/boot/dts/sun4i-a10-cubieboard.dts +8 -0
@@ -33,6 +33,14 @@ }; }; + mmc0: mmc at 01c0f000 { + pinctrl-names = "default", "default"; + pinctrl-0 = <&mmc0_pins_a>; + pinctrl-1 = <&mmc0_cd_pin_reference_design>; + cd-gpios = <&pio 7 1 0>; /* PH1 */ + status = "okay"; + }; + pinctrl at 01c20800 { led_pins_cubieboard: led_pins at 0 { allwinner,pins = "PH20", "PH21";
arch/arm/boot/dts/sun4i-a10.dtsi +54 -0
66 lines not on this page · raw message
PATCH v4 7/7 ARM: dts: sun5i: Add support for mmc
In reply to David Lanzendörfer--- arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dts | 30 +++++++++++++++ arch/arm/boot/dts/sun5i-a10s.dtsi | 44 ++++++++++++++++++++++ arch/arm/boot/dts/sun5i-a13-olinuxino-micro.dts | 15 ++++++++ arch/arm/boot/dts/sun5i-a13-olinuxino.dts | 15 ++++++++ arch/arm/boot/dts/sun5i-a13.dtsi | 37 +++++++++++++++++++ 5 files changed, 141 insertions(+)
arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dts +30 -0
@@ -34,7 +34,37 @@ }; }; + mmc0: mmc at 01c0f000 { + pinctrl-names = "default", "default"; + pinctrl-0 = <&mmc0_pins_a>; + pinctrl-1 = <&mmc0_cd_pin_olinuxino_micro>; + cd-gpios = <&pio 6 1 0>; /* PG1 */ + status = "okay"; + }; + + mmc1: mmc at 01c10000 { + pinctrl-names = "default", "default"; + pinctrl-0 = <&mmc1_pins_a>; + pinctrl-1 = <&mmc1_cd_pin_olinuxino_micro>; + cd-gpios = <&pio 6 13 0>; /* PG13 */ + status = "okay"; + }; + pinctrl at 01c20800 { + mmc0_cd_pin_olinuxino_micro: mmc0_cd_pin at 0 { + allwinner,pins = "PG1"; + allwinner,function = "gpio_in"; + allwinner,drive = <0>; + allwinner,pull = <0>; + }; + + mmc1_cd_pin_olinuxino_micro: mmc1_cd_pin at 0 { + allwinner,pins = "PG13"; + allwinner,function = "gpio_in"; + allwinner,drive = <0>; + allwinner,pull = <0>; + }; + led_pins_olinuxino: led_pins at 0 { allwinner,pins = "PE3"; allwinner,function = "gpio_out";
arch/arm/boot/dts/sun5i-a10s.dtsi +44 -0
56 lines not on this page · raw message
arch/arm/boot/dts/sun5i-a13-olinuxino-micro.dts +15 -0
@@ -20,7 +20,22 @@ compatible = "olimex,a13-olinuxino-micro", "allwinner,sun5i-a13"; soc at 01c00000 { + mmc0: mmc at 01c0f000 { + pinctrl-names = "default", "default"; + pinctrl-0 = <&mmc0_pins_a>; + pinctrl-1 = <&mmc0_cd_pin_olinuxinom>; + cd-gpios = <&pio 6 0 0>; /* PG0 */ + status = "okay"; + }; + pinctrl at 01c20800 { + mmc0_cd_pin_olinuxinom: mmc0_cd_pin at 0 { + allwinner,pins = "PG0"; + allwinner,function = "gpio_in"; + allwinner,drive = <0>; + allwinner,pull = <0>; + }; + led_pins_olinuxinom: led_pins at 0 { allwinner,pins = "PG9"; allwinner,function = "gpio_out";
arch/arm/boot/dts/sun5i-a13-olinuxino.dts +15 -0
@@ -19,7 +19,22 @@ compatible = "olimex,a13-olinuxino", "allwinner,sun5i-a13"; soc at 01c00000 { + mmc0: mmc at 01c0f000 { + pinctrl-names = "default", "default"; + pinctrl-0 = <&mmc0_pins_a>; + pinctrl-1 = <&mmc0_cd_pin_olinuxino>; + cd-gpios = <&pio 6 0 0>; /* PG0 */ + status = "okay"; + }; + pinctrl at 01c20800 { + mmc0_cd_pin_olinuxino: mmc0_cd_pin at 0 { + allwinner,pins = "PG0"; + allwinner,function = "gpio_in"; + allwinner,drive = <0>; + allwinner,pull = <0>; + }; + led_pins_olinuxino: led_pins at 0 { allwinner,pins = "PG9"; allwinner,function = "gpio_out";
arch/arm/boot/dts/sun5i-a13.dtsi +37 -0
@@ -274,6 +274,36 @@ #size-cells = <1>; ranges; + mmc0: mmc at 01c0f000 { + compatible = "allwinner,sun5i-a13-mmc"; + reg = <0x01c0f000 0x1000>; + clocks = <&ahb_gates 8>, <&mmc0_clk>; + clock-names = "ahb", "mod"; + interrupts = <32>; + bus-width = <4>; + status = "disabled"; + }; + + mmc1: mmc at 01c10000 { + compatible = "allwinner,sun5i-a13-mmc"; + reg = <0x01c10000 0x1000>; + clocks = <&ahb_gates 9>, <&mmc1_clk>; + clock-names = "ahb", "mod"; + interrupts = <33>; + bus-width = <4>; + status = "disabled"; + }; + + mmc2: mmc at 01c11000 { + compatible = "allwinner,sun5i-a13-mmc"; + reg = <0x01c11000 0x1000>; + clocks = <&ahb_gates 10>, <&mmc2_clk>; + clock-names = "ahb", "mod"; + interrupts = <34>; + bus-width = <4>; + status = "disabled"; + }; + intc: interrupt-controller at 01c20400 { compatible = "allwinner,sun4i-ic"; reg = <0x01c20400 0x400>;
@@ -326,6 +356,13 @@ allwinner,drive = <0>; allwinner,pull = <0>; }; + + mmc0_pins_a: mmc0 at 0 { + allwinner,pins = "PF0","PF1","PF2","PF3","PF4","PF5"; + allwinner,function = "mmc0"; + allwinner,drive = <3>; + allwinner,pull = <0>; + }; }; timer at 01c20c00 {
Re: [PATCH v4 4/7] ARM: sunxi: Add driver for SD/MMC hosts found on Allwinner sunxi SoCs
In reply to a message not in the archiveÜhel kenal päeval, R, 07.02.2014 kell 22:33, kirjutas David Lanzendörfer:
Quoted 1 line
This is based on the driver Allwinner ships in their Android kernel
sources.
Quoted 5 lines
Initial porting to upstream kernels done by David Lanzendörfer, additional fixes and cleanups by Hans de Goede.
It uses dma in bus-master mode using a built-in designware idmac
controller,
Quoted 4 lines
which is identical to the one found in the mmc-dw hosts. The rest of the host is not identical to mmc-dw.
Signed-off-by David Lanzendörfer
<david.lanzendoerfer-Z7Kmv9EsliU-XMD5yJDbdMReXY1tMh2IBg@public.gmane.org>
Quoted 1 line
Signed-off-by Hans de Goede
<hdegoede-H+wXaHxf7aLQT0dZR+AlfA-XMD5yJDbdMReXY1tMh2IBg@public.gmane.org>
Quoted 4 lines
--- drivers/mmc/host/Kconfig | 7 drivers/mmc/host/Makefile | 2 drivers/mmc/host/sunxi-mci.c | 871
++++++++++++++++++++++++++++++++++++++++++
Quoted 40 lines
drivers/mmc/host/sunxi-mci.h | 239 ++++++++++++ 4 files changed, 1119 insertions(+) create mode 100644 drivers/mmc/host/sunxi-mci.c create mode 100644 drivers/mmc/host/sunxi-mci.hdrivers/mmc/host/Kconfig +7
-0@@ -689,3 +689,10 @@ config MMC_REALTEK_PCI help Say Y here to include driver code to support SD/MMC card interface of Realtek PCI-E card reader + +config MMC_SUNXI + tristate "Allwinner sunxi SD/MMC Host Controller support" + depends on ARCH_SUNXI + help + This selects support for the SD/MMC Host Controller on + Allwinner sunxi SoCs.drivers/mmc/host/Makefile +2
-0@@ -54,6 +54,8 @@ obj-$(CONFIG_MMC_WMT) += wmt-sdmmc.o obj-$(CONFIG_MMC_REALTEK_PCI) += rtsx_pci_sdmmc.o +obj-$(CONFIG_MMC_SUNXI) += sunxi-mci.o + obj-$(CONFIG_MMC_SDHCI_PLTFM) += sdhci-pltfm.o obj-$(CONFIG_MMC_SDHCI_CNS3XXX) += sdhci-cns3xxx.o obj-$(CONFIG_MMC_SDHCI_ESDHC_IMX) += sdhci-esdhc-imx.odrivers/mmc/host/sunxi-mci.c new file +1
-0@@ -0,0 +1,871 @@ +/*
[...]
drivers/mmc/host/sunxi-mci.c line 239
Quoted 9 lines
drivers/mmc/host/sunxi-mci.c new file +9
-0+ +static void sunxi_mmc_dump_errinfo (struct sunxi_mmc_host *smc_host) +{ +struct mmc_command *cmd = smc_host->mrq->cmd; +struct mmc_data *data = smc_host->mrq->data; + +/* For some cmds timeout is normal with sd/mmc cards */ +if ((smc_host->int_sum & SDXC_IntErrBit) == SDXC_RespTimeout && + (cmd->opcode ==5 || cmd->opcode ==52 ))
Aren't these the ones defined in linux/mmc/sdio.h:
5 - SD_IO_SEND_OP_COND
52 - SD_IO_RW_DIRECT
Quoted 17 lines
drivers/mmc/host/sunxi-mci.c new file +17
-0+return ; + +dev_err (mmc_dev (smc_host->mmc), +"smc %d err, cmd %d,%s%s%s%s%s%s%s%s%s%s !!\n" , + smc_host->mmc->index, cmd->opcode, + data ? (data->flags &MMC_DATA_WRITE ?" WR" :" RD" ) :"" , + smc_host->int_sum & SDXC_RespErr ?" RE" :"" , + smc_host->int_sum & SDXC_RespCRCErr ?" RCE" :"" , + smc_host->int_sum & SDXC_DataCRCErr ?" DCE" :"" , + smc_host->int_sum & SDXC_RespTimeout ?" RTO" :"" , + smc_host->int_sum & SDXC_DataTimeout ?" DTO" :"" , + smc_host->int_sum & SDXC_FIFORunErr ?" FE" :"" , + smc_host->int_sum & SDXC_HardWLocked ?" HL" :"" , + smc_host->int_sum & SDXC_StartBitErr ?" SBE" :"" , + smc_host->int_sum & SDXC_EndBitErr ?" EBE" :"" + ); +}
[...]
Quoted 20 lines
drivers/mmc/host/sunxi-mci.c new file +19
-0+static void sunxi_mmc_set_clk_dly (struct sunxi_mmc_host *smc_host, +u32 oclk_dly,u32 sclk_dly) +{ +unsigned long iflags; +struct clk_hw *hw =__clk_get_hw (smc_host->clk_mod); + +spin_lock_irqsave (&smc_host->lock, iflags); +clk_sunxi_mmc_phase_control (hw, sclk_dly, oclk_dly); +spin_unlock_irqrestore (&smc_host->lock, iflags); +} + +struct sunxi_mmc_clk_dly mmc_clk_dly[MMC_CLK_MOD_NUM ] = { + {MMC_CLK_400K ,0 ,7 }, + {MMC_CLK_25M ,0 ,5 }, + {MMC_CLK_50M ,3 ,5 }, + {MMC_CLK_50MDDR ,2 ,4 }, + {MMC_CLK_50MDDR_8BIT ,2 ,4 }, + {MMC_CLK_100M ,1 ,4 }, + {MMC_CLK_200M ,1 ,4 },
Quoted 1 line
From the looks of it, it should be static const, but apparently this was
raising a warning when David did it.. Hints anyone?
Quoted 77 lines
drivers/mmc/host/sunxi-mci.c new file +77
-0+}; + +static void sunxi_mmc_clk_set_rate (struct sunxi_mmc_host *smc_host, +unsigned int rate) +{ +u32 newrate; +u32 src_clk; +u32 oclk_dly; +u32 sclk_dly; +u32 temp; +struct sunxi_mmc_clk_dly *dly =NULL ; + + newrate =clk_round_rate (smc_host->clk_mod, rate); +if (smc_host->clk_mod_rate == newrate) { +dev_dbg (mmc_dev (smc_host->mmc),"clk already %d, rounded %d\n" , + rate, newrate); +return ; + } + +dev_dbg (mmc_dev (smc_host->mmc),"setting clk to %d, rounded %d\n" , + rate, newrate); + +/* setting clock rate */ +clk_disable (smc_host->clk_mod); +clk_set_rate (smc_host->clk_mod, newrate); +clk_enable (smc_host->clk_mod); + smc_host->clk_mod_rate = newrate =clk_get_rate (smc_host->clk_mod); +dev_dbg (mmc_dev (smc_host->mmc),"clk is now %d\n" , newrate); + +sunxi_mmc_oclk_onoff (smc_host,0 ); +/* clear internal divider */ + temp =mci_readl (smc_host,REG_CLKCR ); + temp &= ~0xff ; +mci_writel (smc_host,REG_CLKCR , temp); + +/* determine delays */ +if (rate <=400000 ) { + dly = &mmc_clk_dly[MMC_CLK_400K ]; + }else if (rate <=25000000 ) { + dly = &mmc_clk_dly[MMC_CLK_25M ]; + }else if (rate <=50000000 ) { +if (smc_host->ddr) { +if (smc_host->bus_width ==8 ) + dly = &mmc_clk_dly[MMC_CLK_50MDDR_8BIT ]; +else + dly = &mmc_clk_dly[MMC_CLK_50MDDR ]; + }else { + dly = &mmc_clk_dly[MMC_CLK_50M ]; + } + }else if (rate <=104000000 ) { + dly = &mmc_clk_dly[MMC_CLK_100M ]; + }else if (rate <=208000000 ) { + dly = &mmc_clk_dly[MMC_CLK_200M ]; + }else { + dly = &mmc_clk_dly[MMC_CLK_50M ]; + } + + oclk_dly = dly->oclk_dly; + sclk_dly = dly->sclk_dly; + + src_clk =clk_get_rate (clk_get_parent (smc_host->clk_mod)); + +if (src_clk >=300000000 && src_clk <=400000000 ) { +if (oclk_dly) + oclk_dly--; +if (sclk_dly) + sclk_dly--; + } + +sunxi_mmc_set_clk_dly (smc_host, oclk_dly, sclk_dly); +sunxi_mmc_oclk_onoff (smc_host,1 ); + +/* oclk_onoff sets various irq status bits, clear these */ +mci_writel (smc_host,REG_RINTR , +mci_readl (smc_host,REG_RINTR ) & ~SDXC_SDIOInt); +} +
[...]
drivers/mmc/host/sunxi-mci.h line 4
Quoted 10 lines
drivers/mmc/host/sunxi-mci.h new file +4
-0@@ -0,0 +1,239 @@ +/* +* Driver for sunxi SD/MMC host controllers +* (C) Copyright 2014-2015 Reuuimlla Technology Co., Ltd. +* (C) Copyright 2014-2015 Aaron Maoye
<leafy.myeh-jFKXxz0WcGyYHARAtoI1EgC/[email protected]>
drivers/mmc/host/sunxi-mci.h line 6
Quoted 2 lines
drivers/mmc/host/sunxi-mci.h new file +2
-0+* (C) Copyright 2014-2015 O2S GmbH <www.o2s.ch> +* (C) Copyright 2014-2015 David Lanzendörfer
drivers/mmc/host/sunxi-mci.h line 7
Quoted 1 line
drivers/mmc/host/sunxi-mci.h new file +1
-0+* (C) Copyright 2014-2015 Hans de Goede
<hdegoede-H+wXaHxf7aLQT0dZR+AlfA-XMD5yJDbdMReXY1tMh2IBg@public.gmane.org>
Had to take a look at the calendar...
Quoted 10 lines
drivers/mmc/host/sunxi-mci.h new file +10
-0+* +* 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. +*/ + +#ifndef __SUNXI_MCI_H__ +#define __SUNXI_MCI_H__ +
[...]
drivers/mmc/host/sunxi-mci.h
Quoted 4 lines
drivers/mmc/host/sunxi-mci.h new file +4
-0+ +struct sunxi_idma_des { +u32 config; +#define SDXC_IDMAC_DES0_DIC BIT(1)/* disable interrupt on
completion */
drivers/mmc/host/sunxi-mci.h
Quoted 6 lines
drivers/mmc/host/sunxi-mci.h new file +6
-0+#define SDXC_IDMAC_DES0_LD BIT(2)/* last descriptor */ +#define SDXC_IDMAC_DES0_FD BIT(3)/* first descriptor */ +#define SDXC_IDMAC_DES0_CH BIT(4)/* chain mode */ +#define SDXC_IDMAC_DES0_ER BIT(5)/* end of ring */ +#define SDXC_IDMAC_DES0_CES BIT(30)/* card error summary */ +#define SDXC_IDMAC_DES0_OWN BIT(31)/* 1-idma owns it, 0-host owns it
*/
This #define placement inside the struct looks really weird.
Quoted 13 lines
drivers/mmc/host/sunxi-mci.h new file +13
-0+ +/* +* If the idma-des-size-bits of property is ie 13, bufsize bits are: +* Bits 0-12: buf1 size +* Bits 13-25: buf2 size +* Bits 26-31: not used +* Since we only ever set buf1 size, we can simply store it directly. +*/ +u32 buf_size; +u32 buf_addr_ptr1; +u32 buf_addr_ptr2; +}; +
[...]
Quoted 4 lines
drivers/mmc/host/sunxi-mci.h new file +4
-0+ +#define MMC_CLK_400K 0 +#define MMC_CLK_25M 1 +#define MMC_CLK_50M 2
drivers/mmc/host/sunxi-mci.h line 236
Quoted 10 lines
drivers/mmc/host/sunxi-mci.h new file +10
-0+#define MMC_CLK_50MDDR 3 +#define MMC_CLK_50MDDR_8BIT 4 +#define MMC_CLK_100M 5 +#define MMC_CLK_200M 6 +#define MMC_CLK_MOD_NUM 7 + +struct sunxi_mmc_clk_dly { +u32 mode; +u32 oclk_dly; +u32 sclk_dly;
Do these members have to be u32? They all seem to be smaller than 10.
Signature · 3 lines
You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] For more options, visit https://groups.google.com/groups/opt_out.
Re: [PATCH v4 4/7] ARM: sunxi: Add driver for SD/MMC hosts found on Allwinner sunxi SoCs
Hi
Quoted 4 lines
Quoted 1 line
+ (
cmd->opcode== 5 ||cmd->opcode== 52))Aren't these the ones defined in
linux/mmc/sdio.h:
5 -SD_IO_SEND_OP_COND
52 -SD_IO_RW_DIRECT
Yes. They are...
Changed that.
Also I removed the camel cases and the defines within the struct definition.
Quoted 5 lines
drivers/mmc/host/sunxi-mci.h line 236
Quoted 4 lines
drivers/mmc/host/sunxi-mci.h new file +4
-0+struct sunxi_mmc_clk_dly { +u32 mode; +u32 oclk_dly; +u32 sclk_dly;Do these members have to be u32? They all seem to be smaller than 10.
Yes. Because of situations where it gets used in bit operations, and shorter types mess things up and prevent the driver from working ;-)
cheer
david
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140210/8a8707bf/attachment.sig>
Re: [PATCH v4 4/7] ARM: sunxi: Add driver for SD/MMC hosts found on Allwinner sunxi SoCs
In reply to Priit LaesHi
Quoted 4 lines
Quoted 1 line
+ (
cmd->opcode== 5 ||cmd->opcode== 52))Aren't these the ones defined in
linux/mmc/sdio.h:
5 -SD_IO_SEND_OP_COND
52 -SD_IO_RW_DIRECT
Yes. They are...
Changed that.
Also I removed the camel cases and the defines within the struct definition.
Quoted 5 lines
drivers/mmc/host/sunxi-mci.h line 236
Quoted 4 lines
drivers/mmc/host/sunxi-mci.h new file +4
-0+struct sunxi_mmc_clk_dly { +u32 mode; +u32 oclk_dly; +u32 sclk_dly;Do these members have to be u32? They all seem to be smaller than 10.
Yes. Because of situations where it gets used in bit operations, and shorter types mess things up and prevent the driver from working ;-)
cheer
david
Re: [PATCH v4 4/7] ARM: sunxi: Add driver for SD/MMC hosts found on Allwinner sunxi SoCs
In reply to Priit LaesHi
Quoted 4 lines
Quoted 1 line
+ (
cmd->opcode== 5 ||cmd->opcode== 52))Aren't these the ones defined in
linux/mmc/sdio.h:
5 -SD_IO_SEND_OP_COND
52 -SD_IO_RW_DIRECT
Yes. They are...
Changed that.
Also I removed the camel cases and the defines within the struct definition.
Quoted 5 lines
drivers/mmc/host/sunxi-mci.h line 236
Quoted 4 lines
drivers/mmc/host/sunxi-mci.h new file +4
-0+struct sunxi_mmc_clk_dly { +u32 mode; +u32 oclk_dly; +u32 sclk_dly;Do these members have to be u32? They all seem to be smaller than 10.
Yes. Because of situations where it gets used in bit operations, and shorter types mess things up and prevent the driver from working ;-)
cheer
david
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v4 4/7] ARM: sunxi: Add driver for SD/MMC hosts found on Allwinner sunxi SoCs
In reply to Priit LaesHi
Quoted 4 lines
Quoted 1 line
+ (
cmd->opcode== 5 ||cmd->opcode== 52))Aren't these the ones defined in
linux/mmc/sdio.h:
5 -SD_IO_SEND_OP_COND
52 -SD_IO_RW_DIRECT
Yes. They are...
Changed that.
Also I removed the camel cases and the defines within the struct definition.
Quoted 5 lines
drivers/mmc/host/sunxi-mci.h line 236
Quoted 4 lines
drivers/mmc/host/sunxi-mci.h new file +4
-0+struct sunxi_mmc_clk_dly { +u32 mode; +u32 oclk_dly; +u32 sclk_dly;Do these members have to be u32? They all seem to be smaller than 10.
Yes. Because of situations where it gets used in bit operations, and shorter types mess things up and prevent the driver from working ;-)
cheer
david
Re: [PATCH v4 4/7] ARM: sunxi: Add driver for SD/MMC hosts found on Allwinner sunxi SoCs
In reply to a message not in the archiveHi
Quoted 4 lines
Quoted 1 line
+ (
cmd->opcode== 5 ||cmd->opcode== 52))Aren't these the ones defined in
linux/mmc/sdio.h:
5 -SD_IO_SEND_OP_COND
52 -SD_IO_RW_DIRECT
Yes. They are...
Changed that.
Also I removed the camel cases and the defines within the struct definition.
Quoted 5 lines
drivers/mmc/host/sunxi-mci.h line 236
Quoted 4 lines
drivers/mmc/host/sunxi-mci.h new file +4
-0+struct sunxi_mmc_clk_dly { +u32 mode; +u32 oclk_dly; +u32 sclk_dly;Do these members have to be u32? They all seem to be smaller than 10.
Yes. Because of situations where it gets used in bit operations, and shorter types mess things up and prevent the driver from working ;-)
cheer
david