Re: [PATCH RFC v3] mmc: sdhci-msm: Add support for MSM chipsets

2013-09-05 Thread Georgi Djakov

Hi Ivan,

On 08/23/2013 10:34 AM, Ivan T. Ivanov wrote:

Hi Georgi,

On Tue, 2013-08-20 at 19:44 +0300, Georgi Djakov wrote:

This platform driver adds the support of Secure Digital Host
Controller Interface compliant controller in MSM chipsets.

CC: Asutosh Das asuto...@codeaurora.org
CC: Venkat Gopalakrishnan venk...@codeaurora.org
CC: Sahitya Tummala stumm...@codeaurora.org
CC: Subhash Jadavani subha...@codeaurora.org
Signed-off-by: Georgi Djakov gdja...@mm-sol.com
---
Changes from v2:
- Added DT bindings for clocks
- Moved voltage regulators data to platform data
- Removed unneeded includes
- Removed obsolete and wrapper functions
- Removed error checking where unnecessary
- Removed redundant _clk suffix from clock names
- Just return instead of goto where possible
- Minor fixes



Is this version intermediate step before you address
all previous comments?



+
+static const struct of_device_id sdhci_msm_dt_match[] = {
+   {.compatible = qcom,sdhci-msm},


Missing termination entry


+};
+
+MODULE_DEVICE_TABLE(of, sdhci_msm_dt_match);
+
+static int sdhci_msm_probe(struct platform_device *pdev)
+{
+   struct sdhci_host *host;
+   struct sdhci_pltfm_host *pltfm_host;
+   struct sdhci_msm_host *msm_host;
+   struct resource *core_memres = NULL;
+   int ret = 0, dead = 0;
+   struct pinctrl  *pinctrl;
+
+   msm_host = devm_kzalloc(pdev-dev, sizeof(struct sdhci_msm_host),
+   GFP_KERNEL);
+   if (!msm_host)
+   return -ENOMEM;
+
+   host = sdhci_pltfm_init(pdev, msm_host-sdhci_msm_pdata, 0);
+   if (IS_ERR(host)) {
+   dev_err(mmc_dev(host-mmc), sdhci_pltfm_init error\n);
+   return PTR_ERR(host);
+   }
+
+   pltfm_host = sdhci_priv(host);
+   pltfm_host-priv = msm_host;
+   msm_host-mmc = host-mmc;
+   msm_host-pdev = pdev;
+
+   ret = mmc_of_parse(host-mmc);
+   if (ret)


Shouldn't sdhci_pltfm_init operation be reverted?


+   return ret;
+
+   /* Extract platform data */
+   if (pdev-dev.of_node) {
+   msm_host-pdata = sdhci_msm_populate_pdata(pdev-dev);
+   if (!msm_host-pdata) {
+   dev_err(pdev-dev, DT parsing error\n);
+   goto pltfm_free;
+   }
+   } else {
+   dev_err(pdev-dev, No device tree node\n);
+   goto pltfm_free;
+   }
+
+   /* Setup pins */
+   pinctrl = devm_pinctrl_get_select_default(pdev-dev);
+   if (IS_ERR(pinctrl))
+   dev_warn(pdev-dev, pins are not configured by the driver\n);
+
+   /* Setup Clocks */
+
+   /* Setup SDCC bus voter clock. */
+   msm_host-bus_clk = devm_clk_get(pdev-dev, bus);
+   if (!IS_ERR_OR_NULL(msm_host-bus_clk)) {
+   /* Vote for max. clk rate for max. performance */
+   ret = clk_set_rate(msm_host-bus_clk, INT_MAX);
+   if (ret)
+   goto pltfm_free;
+   ret = clk_prepare_enable(msm_host-bus_clk);
+   if (ret)
+   goto pltfm_free;
+   }
+
+   /* Setup main peripheral bus clock */
+   msm_host-pclk = devm_clk_get(pdev-dev, iface);
+   if (!IS_ERR(msm_host-pclk)) {
+   ret = clk_prepare_enable(msm_host-pclk);
+   if (ret) {
+   dev_err(pdev-dev,
+   Main peripheral clock setup failed (%d)\n,
+   ret);
+   goto bus_clk_disable;
+   }
+   }
+
+   /* Setup SDC MMC clock */
+   msm_host-clk = devm_clk_get(pdev-dev, core);
+   if (IS_ERR(msm_host-clk)) {
+   ret = PTR_ERR(msm_host-clk);
+   dev_err(pdev-dev, SDC MMC clock setup failed (%d)\n, ret);
+   goto pclk_disable;
+   }
+
+   ret = clk_prepare_enable(msm_host-clk);
+   if (ret)
+   goto pclk_disable;
+
+   /* Setup regulators */
+   ret = sdhci_msm_vreg_init(pdev-dev, msm_host-pdata, true);
+   if (ret) {
+   dev_err(pdev-dev, Regulator setup failed (%d)\n, ret);
+   goto clk_disable;
+   }
+
+   /* Reset the core and Enable SDHC mode */
+   core_memres = platform_get_resource_byname(pdev,
+  IORESOURCE_MEM, core_mem);
+   msm_host-core_mem = devm_ioremap(pdev-dev, core_memres-start,
+ resource_size(core_memres));
+
+   if (!msm_host-core_mem) {
+   dev_err(pdev-dev, Failed to remap registers\n);
+   ret = -ENOMEM;
+   goto vreg_deinit;
+   }
+
+   /* Set SW_RST bit in POWER register (Offset 0x0) */
+   writel_relaxed(CORE_SW_RST, msm_host-core_mem + CORE_POWER);
+   /* Set HC_MODE_EN bit in HC_MODE register */
+   writel_relaxed(HC_MODE_EN, (msm_host-core_mem + CORE_HC_MODE));
+
+   /*
+   

Re: [PATCH RFC v3] mmc: sdhci-msm: Add support for MSM chipsets

2013-09-05 Thread Georgi Djakov

Hi Jaehoon,

On 08/27/2013 11:55 AM, Jaehoon Chung wrote:

Hi Georgi,

I found the sdhci_msm_vreg_reset(). Why do you run enable-disable?

+/*
+ * Reset vreg by ensuring it is off during probe. A call
+ * to enable vreg is needed to balance disable vreg
+ */
+static int sdhci_msm_vreg_reset(struct sdhci_msm_pltfm_data *pdata)

I think that controller didn't have responsibility to ensure whether power is 
enabled or not at probing time.
If just needed to balance vreg, then i think this function can be removed.
How about?

Also before using regulator_is_enabled(), i had found the hole for balancing 
the vreg.


Thank you! I'll remove this function.

BR,
Georgi

--
To unsubscribe from this list: send the line unsubscribe linux-arm-msm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 1/2] ARM: msm: Add support for MSM8974 Dragonboard

2013-09-05 Thread Rohit Vaswani
This patch adds basic board support for MSM8974 Dragonboard
which belongs to the Snapdragon 800 family.
For now, just support a basic machine with device tree.

Signed-off-by: Rohit Vaswani rvasw...@codeaurora.org
---
 arch/arm/boot/dts/Makefile|  3 ++-
 arch/arm/boot/dts/msm8974-db.dts  |  7 +++
 arch/arm/boot/dts/msm8974.dtsi| 30 ++
 arch/arm/mach-msm/Kconfig | 20 ++--
 arch/arm/mach-msm/Makefile|  1 +
 arch/arm/mach-msm/board-dt-8974.c | 23 +++
 6 files changed, 81 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/boot/dts/msm8974-db.dts
 create mode 100644 arch/arm/boot/dts/msm8974.dtsi
 create mode 100644 arch/arm/mach-msm/board-dt-8974.c

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 69193be..95ace01 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -103,7 +103,8 @@ dtb-$(CONFIG_ARCH_KIRKWOOD) += kirkwood-cloudbox.dtb \
kirkwood-openblocks_a6.dtb
 dtb-$(CONFIG_ARCH_MARCO) += marco-evb.dtb
 dtb-$(CONFIG_ARCH_MSM) += msm8660-surf.dtb \
-   msm8960-cdp.dtb
+   msm8960-cdp.dtb \
+   msm8974-db.dtb
 dtb-$(CONFIG_ARCH_MVEBU) += armada-370-db.dtb \
armada-370-mirabox.dtb \
armada-370-netgear-rn102.dtb \
diff --git a/arch/arm/boot/dts/msm8974-db.dts b/arch/arm/boot/dts/msm8974-db.dts
new file mode 100644
index 000..74106a8
--- /dev/null
+++ b/arch/arm/boot/dts/msm8974-db.dts
@@ -0,0 +1,7 @@
+/include/ msm8974.dtsi
+
+/ {
+   model = Qualcomm MSM8974 Dragonboard;
+   compatible = qcom,msm8974-db, qcom,msm8974;
+};
+
diff --git a/arch/arm/boot/dts/msm8974.dtsi b/arch/arm/boot/dts/msm8974.dtsi
new file mode 100644
index 000..aa3bb2f
--- /dev/null
+++ b/arch/arm/boot/dts/msm8974.dtsi
@@ -0,0 +1,30 @@
+/dts-v1/;
+
+/include/ skeleton.dtsi
+
+/ {
+   model = Qualcomm MSM8974;
+   compatible = qcom,msm8974;
+   interrupt-parent = intc;
+
+   soc: soc { };
+};
+
+soc {
+   intc: interrupt-controller@f900 {
+   compatible = qcom,msm-qgic2;
+   interrupt-controller;
+   #interrupt-cells = 3;
+   reg =  0xf900 0x1000 ,
+  0xf9002000 0x1000 ;
+   };
+
+   timer {
+   compatible = arm,armv7-timer;
+   interrupts = 1 2 0xf08,
+1 3 0xf08,
+1 4 0xf08,
+1 1 0xf08;
+   clock-frequency = 1920;
+   };
+};
diff --git a/arch/arm/mach-msm/Kconfig b/arch/arm/mach-msm/Kconfig
index 905efc8..499e8fe 100644
--- a/arch/arm/mach-msm/Kconfig
+++ b/arch/arm/mach-msm/Kconfig
@@ -1,12 +1,12 @@
 if ARCH_MSM
 
 comment Qualcomm MSM SoC Type
-   depends on (ARCH_MSM8X60 || ARCH_MSM8960)
+   depends on ARCH_MSM_DT
 
 choice
prompt Qualcomm MSM SoC Type
default ARCH_MSM7X00A
-   depends on !(ARCH_MSM8X60 || ARCH_MSM8960)
+   depends on !ARCH_MSM_DT
 
 config ARCH_MSM7X00A
bool MSM7x00A / MSM7x01A
@@ -60,6 +60,19 @@ config ARCH_MSM8960
select MSM_SCM if SMP
select USE_OF
 
+config ARCH_MSM8974
+   bool MSM8974
+   select ARM_GIC
+   select CPU_V7
+   select HAVE_ARM_ARCH_TIMER
+   select HAVE_SMP
+   select MSM_SCM if SMP
+   select USE_OF
+
+config ARCH_MSM_DT
+   def_bool y
+   depends on (ARCH_MSM8X60 || ARCH_MSM8960 || ARCH_MSM8974)
+
 config MSM_HAS_DEBUG_UART_HS
bool
 
@@ -68,6 +81,7 @@ config MSM_SOC_REV_A
 
 config  ARCH_MSM_ARM11
bool
+
 config  ARCH_MSM_SCORPION
bool
 
@@ -75,6 +89,7 @@ config  MSM_VIC
bool
 
 menu Qualcomm MSM Board Type
+   depends on !ARCH_MSM_DT
 
 config MACH_HALIBUT
depends on ARCH_MSM
@@ -122,6 +137,7 @@ config MSM_SMD
 
 config MSM_GPIOMUX
bool
+   depends on !ARCH_MSM_DT
help
  Support for MSM V1 TLMM GPIOMUX architecture.
 
diff --git a/arch/arm/mach-msm/Makefile b/arch/arm/mach-msm/Makefile
index d872634..28e5c21 100644
--- a/arch/arm/mach-msm/Makefile
+++ b/arch/arm/mach-msm/Makefile
@@ -28,5 +28,6 @@ obj-$(CONFIG_ARCH_MSM7X30) += board-msm7x30.o 
devices-msm7x30.o
 obj-$(CONFIG_ARCH_QSD8X50) += board-qsd8x50.o devices-qsd8x50.o
 obj-$(CONFIG_ARCH_MSM8X60) += board-dt-8660.o
 obj-$(CONFIG_ARCH_MSM8960) += board-dt-8960.o
+obj-$(CONFIG_ARCH_MSM8974) += board-dt-8974.o
 obj-$(CONFIG_MSM_GPIOMUX) += gpiomux.o
 obj-$(CONFIG_ARCH_QSD8X50) += gpiomux-8x50.o
diff --git a/arch/arm/mach-msm/board-dt-8974.c 
b/arch/arm/mach-msm/board-dt-8974.c
new file mode 100644
index 000..697623e
--- /dev/null
+++ b/arch/arm/mach-msm/board-dt-8974.c
@@ -0,0 +1,23 @@
+/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software 

[PATCHv2 2/2] defconfig: msm_defconfig: Enable CONFIG_ARCH_MSM8974

2013-09-05 Thread Rohit Vaswani
This patch enables MSM8974 build support.

Signed-off-by: Rohit Vaswani rvasw...@codeaurora.org
---
 arch/arm/configs/msm_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/msm_defconfig b/arch/arm/configs/msm_defconfig
index 690b5f9..0ed32e5 100644
--- a/arch/arm/configs/msm_defconfig
+++ b/arch/arm/configs/msm_defconfig
@@ -20,6 +20,7 @@ CONFIG_PARTITION_ADVANCED=y
 CONFIG_ARCH_MSM=y
 CONFIG_ARCH_MSM8X60=y
 CONFIG_ARCH_MSM8960=y
+CONFIG_ARCH_MSM8974=y
 CONFIG_SMP=y
 CONFIG_PREEMPT=y
 CONFIG_AEABI=y
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

--
To unsubscribe from this list: send the line unsubscribe linux-arm-msm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html