ARM: sunxi: Add driver for SD/MMC hosts found on allwinner sunxi SOCs
Subsystems (5)
v2 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.
This patchset is the second attempt to send this driver upstream.
I'm looking forward to the acceptance of this patchset into mainline.
best 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 (1):
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-sunxi.c | 35 + drivers/mmc/host/Kconfig | 8 drivers/mmc/host/Makefile | 2 drivers/mmc/host/sunxi-mci.c | 848 ++++++++++++++++++++++ drivers/mmc/host/sunxi-mci.h | 239 ++++++ include/linux/clk/sunxi.h | 22 + 18 files changed, 1465 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 v2 1/6 ARM: sunxi: Add driver for SD/MMC hosts found on Allwinner sunxi SoCs
This is based on the driver Allwinner ships in the 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 | 8 drivers/mmc/host/Makefile | 2 drivers/mmc/host/sunxi-mci.c | 848 ++++++++++++++++++++++++++++++++++++++++++ drivers/mmc/host/sunxi-mci.h | 239 ++++++++++++ 4 files changed, 1097 insertions(+) create mode 100644 drivers/mmc/host/sunxi-mci.c create mode 100644 drivers/mmc/host/sunxi-mci.h
drivers/mmc/host/Kconfig +8 -0
@@ -689,3 +689,11 @@ 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 + default y + 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 +848 -0
848 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 v2 2/6 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 v2 3/6 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 v2 4/6 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 v2 5/6 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 v2 6/6 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 {
Hi
I forgot to mention that the autoparenting patch of Emilios is a crucial depency...
http://git.o2s.ch/?p=linux-next.git;a=commit;h=f8e936772672a3a6ec934558d2a7aef030c663c4
Without it, the clock will return the wrong value and the card will refuse to initialize
regards
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/20140204/201e6182/attachment.sig>
Hi David,
Quoted 8 lines · David Lanzend?rfer
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.
This patchset is the second attempt to send this driver upstream.
I'm looking forward to the acceptance of this patchset into mainline.
I have four comments here:
- Read Documentation/SubmittingPatches, especially Section 5 and 12 (hints, you forgot the clock maintainers for your clock patches and you didn't put any signed-off-by tags)
- You ignored pretty much all the comments that were made during the review of the first version. Go through
http://lists.infradead.org/pipermail/linux-arm-kernel/2013-December/219339.html
and address the comments that were made.
- Each of your patches should compile. Fix the order of your patches.
- Submit a v3, with the changes you made. Otherwise we have no way of knowing what have been fixed and what didn't
Looking forward for the next iteration!
Thanks,
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140205/739e5515/attachment.sig>
Hi Maxime
Quoted 4 lines
I have four comments here:
- ReadDocumentation/SubmittingPatches, especially Section 5 and 12 (hints, you forgot the clock maintainers for your clock patches and you didn't put any signed-off-by tags)
Oops. I added signed-offs now
Quoted 2 lines
- You ignored pretty much all the comments that were made during the review of the first version. Go through
Uh? I just fixed the commits and squashed them together for easier handling. I'm even using mmc_of_parse now...
Quoted 4 lines
http://lists.infradead.org/pipermail/linux-arm-kernel/2013-December/219339.
html and address the comments that were made.
- Each of your patches should compile. Fix the order of your patches.
Done.
Quoted 2 lines
- Submit a v3, with the changes you made. Otherwise we have no way of knowing what have been fixed and what didn't
Too many patches would be bloaty.
That's why I've squashed them into small and corrected patches.
Quoted 1 line
Looking forward for the next iteration!
Good :-)
You can have a look at the recent status here:
http://git.o2s.ch/?p=linux-next.git;a=shortlog;h=refs/heads/20140205
cheers
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/20140205/d03c7f13/attachment.sig>
Hi David,
Quoted 14 lines · David Lanzend?rfer
Hi Maxime
Quoted 4 lines
I have four comments here:
- ReadDocumentation/SubmittingPatches, especially Section 5 and 12 (hints, you forgot the clock maintainers for your clock patches and you didn't put any signed-off-by tags)Oops. I added signed-offs now
Quoted 2 lines
- You ignored pretty much all the comments that were made during the review of the first version. Go through
Uh? I just fixed the commits and squashed them together for easier handling. I'm even using
mmc_of_parsenow...Quoted 4 lines
http://lists.infradead.org/pipermail/linux-arm-kernel/2013-December/219339.
html and address the comments that were made.
- Each of your patches should compile. Fix the order of your patches.
Quoted 5 lines
Done.
Quoted 2 lines
- Submit a v3, with the changes you made. Otherwise we have no way of knowing what have been fixed and what didn't
Too many patches would be bloaty.
That's why I've squashed them into small and corrected patches.
The squashing is fine, what Maxime means is that normally you would include a changelog in the coverletter (the [patch 0/x] mail) documenting changes done since the previous posting of the patchset, so for v3 that would have been something like:
Changes since v1:
-use mmc_of_parse instead of diy dt parsing
-add nodes for all mmc controller to the dtsi files, including sofar unused
controllers
Changes since v2:
-Add missing Signed-off-by tags
-stop using __raw_readl / __raw_writel so that barriers are properly used
I've probably forgotten a few things, it would be good if you could send a reply to the:
"[PATCH v3 0/7] ARM: sunxi: Add driver for SD/MMC hosts found on allwinner sunxi SOCs" mail with the above changelog, amended with whatever I've forgotten to add to the above changelog
Thanks & Regards,
Hans