Skip to contentSkip to conversation

MSM clock driver updates

PATCH New Stephen Boyd 1 participant 23 messages Dec 17, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover MSM clock driver updates

This series of patches syncs the MSM clock code in Linus' tree with the MSM tree @ codeaurora.org. They're prepared against the msm-core tree (git://codeaurora.org/quic/kernel/davidb/linux-msm.git msm-core).

* 1 - 4 are cleanups and minor additions to the existing clock driver

* 5 - 6 add support for the 7x30 local clock driver

* 7 - 10 add support for the 8x60 local clock driver; refactor the 7x30 driver into a generic driver and remove the dummy clock driver in use by 8x60

* 11 - 12 add debugfs aides for locally controlled clocks

* 13 - 17 implement clock rate voting for clocks with multiple consumers where each consumer requires different minimum rates

* 18 moves the clock driver to clkdev

* 19 - 22 moves the iommu driver to proper usage of the clock driver

I understand the diffstat is rather large, but please review. All feedback is welcome.

Matt Wagantall (5):
msm: clock: Move debugfs code from clock.c to clock-debug.c
msm: clock: Refactor clock-7x30 into generic clock-local driver
msm: clock-8x60: Add msm8x60 local clock driver
msm: clock Add debugfs interface to measure clock rates
msm: clock: Add list_rate debugfs nodes for locally-controlled clocks

Saravana Kannan (1):
msm: clock-7x30: Add 7x30 local clock driver

Stepan Moskovchenko (3):
msm: iommu: Add bus clocks to platform data
msm: iommu: Clock control for the IOMMU driver
msm: iommu: Rework clock logic and add IOMMU bus clock control

Stephen Boyd (13):
msm: clock: Remove unused code and definitions
msm: clock: Invert debugfs directory layout
msm: clock: Add support for more proc_comm clocks
msm: clock-7x30: Update clock table
msm: clock: Remove references to clk_ops_pcom
msm: Move 8x60 to the real clock driver
msm: clock: Push down clock count and locking into sub drivers
msm: clock: Support clk_set_parent() clk_ops
msm: clock-pcom: Add pbus specific clock ops
msm: clock: Implement rate voting
msm: Migrate to clock rate voting
msm: clock: Migrate to clkdev
msm: clock-8x60: Don't keep IOMMU clocks on at boot

 arch/arm/Kconfig                                |    1 +
 arch/arm/mach-msm/Makefile                      |   10 +-
 arch/arm/mach-msm/board-msm8x60.c               |    8 +-
 arch/arm/mach-msm/clock-7x30.c                  | 1166 ++++++++++++++
 arch/arm/mach-msm/clock-7x30.h                  |  265 ++--
 arch/arm/mach-msm/clock-8x60.c                  | 1896 +++++++++++++++++++++++
 arch/arm/mach-msm/clock-8x60.h                  |  218 +++
 arch/arm/mach-msm/clock-debug.c                 |  176 +++
 arch/arm/mach-msm/clock-local.c                 |  696 +++++++++
 arch/arm/mach-msm/clock-local.h                 |  233 +++
 arch/arm/mach-msm/clock-pcom.c                  |  102 ++-
 arch/arm/mach-msm/clock-pcom.h                  |   21 +-
 arch/arm/mach-msm/clock-voter.c                 |  202 +++
 arch/arm/mach-msm/clock-voter.h                 |   54 +
 arch/arm/mach-msm/clock.c                       |  244 +---
 arch/arm/mach-msm/clock.h                       |   70 +-
 arch/arm/mach-msm/devices-msm7x00.c             |   32 +-
 arch/arm/mach-msm/devices-msm7x30.c             |  170 ++-
 arch/arm/mach-msm/devices-msm8x60-iommu.c       |    5 -
 arch/arm/mach-msm/devices-msm8x60.c             |  183 +++
 arch/arm/mach-msm/devices-qsd8x50.c             |   29 +-
 arch/arm/mach-msm/devices.h                     |    9 +-
 arch/arm/mach-msm/include/mach/board.h          |    4 +-
 arch/arm/mach-msm/include/mach/clkdev.h         |   23 +
 arch/arm/mach-msm/include/mach/iommu.h          |   12 +-
 arch/arm/mach-msm/include/mach/msm_iomap-8x60.h |   12 +
 arch/arm/mach-msm/io.c                          |    3 +
 arch/arm/mach-msm/iommu.c                       |   57 +-
 arch/arm/mach-msm/iommu_dev.c                   |  204 ++-
 arch/arm/mach-msm/proc_comm.h                   |    1 +
 30 files changed, 5524 insertions(+), 582 deletions(-)
 create mode 100644 arch/arm/mach-msm/clock-7x30.c
 create mode 100644 arch/arm/mach-msm/clock-8x60.c
 create mode 100644 arch/arm/mach-msm/clock-8x60.h
 create mode 100644 arch/arm/mach-msm/clock-debug.c
 create mode 100644 arch/arm/mach-msm/clock-local.c
 create mode 100644 arch/arm/mach-msm/clock-local.h
 create mode 100644 arch/arm/mach-msm/clock-voter.c
 create mode 100644 arch/arm/mach-msm/clock-voter.h
 create mode 100644 arch/arm/mach-msm/devices-msm8x60.c
 create mode 100644 arch/arm/mach-msm/include/mach/clkdev.h
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#1 lore raw

PATCH 1/22 msm: clock: Remove unused code and definitions

Remove dead code and push out clock-7x30.h and clock-pcom.h to where they are actually used.

---
 arch/arm/mach-msm/board-msm8x60.c   |    5 ----
 arch/arm/mach-msm/clock-pcom.c      |    1 +
 arch/arm/mach-msm/clock.c           |   21 ++--------------
 arch/arm/mach-msm/clock.h           |   45 -----------------------------------
 arch/arm/mach-msm/devices-msm7x30.c |    1 +
 arch/arm/mach-msm/devices-qsd8x50.c |    1 +
 6 files changed, 6 insertions(+), 68 deletions(-)
arch/arm/mach-msm/board-msm8x60.c +0 -5
index 7486a68..852428b 100644
@@ -30,11 +30,6 @@
 
 void __iomem *gic_cpu_base_addr;
 
-unsigned long clk_get_max_axi_khz(void)
-{
-	return 0;
-}
-
 static void __init msm8x60_map_io(void)
 {
 	msm_map_msm8x60_io();
arch/arm/mach-msm/clock-pcom.c +1 -0
index a3b4562..8c4e867 100644
@@ -20,6 +20,7 @@
 
 #include "proc_comm.h"
 #include "clock.h"
+#include "clock-pcom.h"
 
 /*
  * glue for the proc_comm interface
arch/arm/mach-msm/clock.c +3 -18
index 2069bfa..8f71f8d 100644
@@ -29,6 +29,7 @@
 #include "clock.h"
 #include "proc_comm.h"
 #include "clock-7x30.h"
+#include "clock-pcom.h"
 
 static DEFINE_MUTEX(clocks_mutex);
 static DEFINE_SPINLOCK(clocks_lock);
@@ -37,13 +38,6 @@ struct clk *msm_clocks;
 unsigned msm_num_clocks;
 
 /*
- * Bitmap of enabled clocks, excluding ACPU which is always
- * enabled
- */
-static DECLARE_BITMAP(clock_map_enabled, NR_CLKS);
-static DEFINE_SPINLOCK(clock_map_lock);
-
-/*
  * Standard clock functions defined in include/linux/clk.h
  */
 struct clk *clk_get(struct device *dev, const char *id)
@@ -77,12 +71,8 @@ int clk_enable(struct clk *clk)
 	unsigned long flags;
 	spin_lock_irqsave(&clocks_lock, flags);
 	clk->count++;
-	if (clk->count == 1) {
+	if (clk->count == 1)
 		clk->ops->enable(clk->id);
-		spin_lock(&clock_map_lock);
-		clock_map_enabled[BIT_WORD(clk->id)] |= BIT_MASK(clk->id);
-		spin_unlock(&clock_map_lock);
-	}
 	spin_unlock_irqrestore(&clocks_lock, flags);
 	return 0;
 }
@@ -94,12 +84,8 @@ void clk_disable(struct clk *clk)
 	spin_lock_irqsave(&clocks_lock, flags);
 	BUG_ON(clk->count == 0);
 	clk->count--;
-	if (clk->count == 0) {
+	if (clk->count == 0)
 		clk->ops->disable(clk->id);
-		spin_lock(&clock_map_lock);
-		clock_map_enabled[BIT_WORD(clk->id)] &= ~BIT_MASK(clk->id);
-		spin_unlock(&clock_map_lock);
-	}
 	spin_unlock_irqrestore(&clocks_lock, flags);
 }
 EXPORT_SYMBOL(clk_disable);
@@ -196,7 +182,6 @@ void __init msm_clock_init(struct clk *clock_tbl, unsigned num_clocks)
 {
 	unsigned n;
 
-	spin_lock_init(&clocks_lock);
 	mutex_lock(&clocks_mutex);
 	msm_clocks = clock_tbl;
 	msm_num_clocks = num_clocks;
arch/arm/mach-msm/clock.h +0 -45

60 lines not on this page · raw message

arch/arm/mach-msm/devices-msm7x30.c +1 -0
index 7fcf2e3..2a9958f 100644
@@ -28,6 +28,7 @@
 #include <asm/mach/flash.h>
 
 #include "clock-pcom.h"
+#include "clock-7x30.h"
 
 #include <mach/mmc.h>
 
arch/arm/mach-msm/devices-qsd8x50.c +1 -0
index 6fe67c5..f92c5c2 100644
@@ -27,6 +27,7 @@
 #include <asm/mach/flash.h>
 
 #include <mach/mmc.h>
+#include "clock-pcom.h"
 
 static struct resource resources_uart3[] = {
 	{
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#2 lore raw

PATCH 2/22 msm: clock: Move debugfs code from clock.c to clock-debug.c

In reply to Stephen Boyd

From: Matt Wagantall <[email protected]>

The clock debugfs code is large enough, and easy enough to separate, that it deserves its own file which is compiled only when CONFIG_DEBUG_FS is enabled.

Also, cleanup header file #includes that are no longer required.

---
 arch/arm/mach-msm/Makefile      |    3 +
 arch/arm/mach-msm/clock-debug.c |  133 +++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-msm/clock.c       |  127 ++-----------------------------------
 arch/arm/mach-msm/clock.h       |    9 +++
 4 files changed, 150 insertions(+), 122 deletions(-)
 create mode 100644 arch/arm/mach-msm/clock-debug.c
arch/arm/mach-msm/Makefile +3 -0
index 59646bb..dc8ef08 100644
@@ -1,4 +1,7 @@
 obj-y += io.o idle.o timer.o
+ifdef CONFIG_MSM_PROC_COMM
+obj-$(CONFIG_DEBUG_FS) += clock-debug.o
+endif
 ifndef CONFIG_ARCH_MSM8X60
 obj-y += acpuclock-arm11.o
 obj-y += dma.o
arch/arm/mach-msm/clock-debug.c new file +133 -0

133 lines not on this page · raw message

arch/arm/mach-msm/clock.c +5 -122

163 lines not on this page · raw message

arch/arm/mach-msm/clock.h +9 -0
index 6a0cade..70216b0 100644
@@ -17,6 +17,7 @@
 #ifndef __ARCH_ARM_MACH_MSM_CLOCK_H
 #define __ARCH_ARM_MACH_MSM_CLOCK_H
 
+#include <linux/init.h>
 #include <linux/list.h>
 #include <mach/clk.h>
 
@@ -61,4 +62,12 @@ struct clk {
 #define CLK_MAX CLKFLAG_MAX
 #define CLK_MINMAX (CLK_MIN | CLK_MAX)
 
+#ifdef CONFIG_DEBUG_FS
+int __init clock_debug_init(void);
+int __init clock_debug_add(struct clk *clock);
+#else
+static inline int __init clock_debug_init(void) { return 0; }
+static inline int __init clock_debug_add(struct clk *clock) { return 0; }
+#endif
+
 #endif
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#3 lore raw

PATCH 3/22 msm: clock: Invert debugfs directory layout

In reply to Stephen Boyd

There are currently 3 separate directories for clock debugging in
debugfs: clk_enable, clk_rate, and clk_local. Each of these directories contains a list of clocks. This is rather annoying when you are focusing on one clock and want to enable/disable it and then check its rate. You either have to cd to the other directory or cat ../clk_rate/<clk>.

Invert the layout so that there is one clock directory containing a directory for each clock. Inside each respective clock directory place an enable, rate, and is_local file relating to the clk_enable, clk_disable, and clk_local directories that exist today.

---
 arch/arm/mach-msm/clock-debug.c |   48 ++++++++++++++++++--------------------
 1 files changed, 23 insertions(+), 25 deletions(-)
arch/arm/mach-msm/clock-debug.c +23 -25
index 6f603ed..b67b9e82 100644
@@ -87,47 +87,45 @@ static int clock_debug_local_get(void *data, u64 *val)
 DEFINE_SIMPLE_ATTRIBUTE(clock_local_fops, clock_debug_local_get,
 			NULL, "%llu\n");
 
-static struct dentry *dent_rate, *dent_enable, *dent_local;
+static struct dentry *debugfs_base;
 
 int __init clock_debug_init(void)
 {
-	dent_rate = debugfs_create_dir("clk_rate", 0);
-	if (!dent_rate)
-		goto err;
-
-	dent_enable = debugfs_create_dir("clk_enable", 0);
-	if (!dent_enable)
-		goto err;
-
-	dent_local = debugfs_create_dir("clk_local", NULL);
-	if (!dent_local)
-		goto err;
-
+	debugfs_base = debugfs_create_dir("clk", NULL);
+	if (!debugfs_base)
+		return -ENOMEM;
 	return 0;
-err:
-	debugfs_remove(dent_local);
-	debugfs_remove(dent_enable);
-	debugfs_remove(dent_rate);
-	return -ENOMEM;
 }
 
 int __init clock_debug_add(struct clk *clock)
 {
 	char temp[50], *ptr;
+	struct dentry *clk_dir;
 
-	if (!dent_rate || !dent_enable || !dent_local)
+	if (!debugfs_base)
 		return -ENOMEM;
 
 	strncpy(temp, clock->dbg_name, ARRAY_SIZE(temp)-1);
 	for (ptr = temp; *ptr; ptr++)
 		*ptr = tolower(*ptr);
 
-	debugfs_create_file(temp, S_IRUGO | S_IWUSR, dent_rate,
-			    clock, &clock_rate_fops);
-	debugfs_create_file(temp, S_IRUGO | S_IWUSR, dent_enable,
-			    clock, &clock_enable_fops);
-	debugfs_create_file(temp, S_IRUGO, dent_local,
-			    clock, &clock_local_fops);
+	clk_dir = debugfs_create_dir(temp, debugfs_base);
+	if (!clk_dir)
+		return -ENOMEM;
+
+	if (!debugfs_create_file("rate", S_IRUGO | S_IWUSR, clk_dir,
+				clock, &clock_rate_fops))
+		goto error;
 
+	if (!debugfs_create_file("enable", S_IRUGO | S_IWUSR, clk_dir,
+				clock, &clock_enable_fops))
+		goto error;
+
+	if (!debugfs_create_file("is_local", S_IRUGO, clk_dir, clock,
+				&clock_local_fops))
+		goto error;
 	return 0;
+error:
+	debugfs_remove_recursive(clk_dir);
+	return -ENOMEM;
 }
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#4 lore raw

PATCH 4/22 msm: clock: Add support for more proc_comm clocks

In reply to Stephen Boyd

Support the CE_CLK and CODEC_SSBI_CLK. Also add support for sdc, uart, and i2c clocks on targets which support proc_comm clocks.

---
 arch/arm/mach-msm/clock-pcom.h      |    4 +++-
 arch/arm/mach-msm/devices-msm7x30.c |    2 ++
 arch/arm/mach-msm/devices-qsd8x50.c |   14 ++++++++++++++
 3 files changed, 19 insertions(+), 1 deletions(-)
arch/arm/mach-msm/clock-pcom.h +3 -1
index 17d027b..2c813f1 100644
@@ -132,8 +132,10 @@
 #define P_CSI1_P_CLK		97
 #define P_GSBI_CLK		98
 #define P_GSBI_P_CLK		99
+#define P_CE_CLK		100 /* Crypto engine */
+#define P_CODEC_SSBI_CLK	101
 
-#define P_NR_CLKS		100
+#define P_NR_CLKS		102
 
 struct clk_ops;
 extern struct clk_ops clk_ops_pcom;
arch/arm/mach-msm/devices-msm7x30.c +2 -0
index 2a9958f..2816be3 100644
@@ -62,6 +62,8 @@ struct clk msm_clocks_7x30[] = {
 	CLK_PCOM("adsp_clk",	ADSP_CLK,	NULL, 0),
 	CLK_PCOM("cam_m_clk",	CAM_M_CLK,	NULL, 0),
 	CLK_PCOM("camif_pad_pclk",	CAMIF_PAD_P_CLK,	NULL, OFF),
+	CLK_PCOM("ce_clk",	CE_CLK,	NULL, 0),
+	CLK_PCOM("codec_ssbi_clk",	CODEC_SSBI_CLK,	NULL, 0),
 	CLK_PCOM("ebi1_clk",	EBI1_CLK,	NULL, CLK_MIN),
 	CLK_PCOM("ecodec_clk",	ECODEC_CLK,	NULL, 0),
 	CLK_PCOM("emdh_clk",	EMDH_CLK,	NULL, OFF | CLK_MINMAX),
arch/arm/mach-msm/devices-qsd8x50.c +14 -0
index f92c5c2..271c8bb 100644
@@ -56,12 +56,14 @@ struct platform_device msm_device_smd = {
 
 struct clk msm_clocks_8x50[] = {
 	CLK_PCOM("adm_clk",	ADM_CLK,	NULL, 0),
+	CLK_PCOM("ce_clk",	CE_CLK,		NULL, 0),
 	CLK_PCOM("ebi1_clk",	EBI1_CLK,	NULL, CLK_MIN),
 	CLK_PCOM("ebi2_clk",	EBI2_CLK,	NULL, 0),
 	CLK_PCOM("ecodec_clk",	ECODEC_CLK,	NULL, 0),
 	CLK_PCOM("emdh_clk",	EMDH_CLK,	NULL, OFF | CLK_MINMAX),
 	CLK_PCOM("gp_clk",	GP_CLK,		NULL, 0),
 	CLK_PCOM("grp_clk",	GRP_3D_CLK,	NULL, 0),
+	CLK_PCOM("i2c_clk",	I2C_CLK,	NULL, 0),
 	CLK_PCOM("icodec_rx_clk",	ICODEC_RX_CLK,	NULL, 0),
 	CLK_PCOM("icodec_tx_clk",	ICODEC_TX_CLK,	NULL, 0),
 	CLK_PCOM("imem_clk",	IMEM_CLK,	NULL, OFF),
@@ -74,12 +76,24 @@ struct clk msm_clocks_8x50[] = {
 	CLK_PCOM("pbus_clk",	PBUS_CLK,	NULL, CLK_MIN),
 	CLK_PCOM("pcm_clk",	PCM_CLK,	NULL, 0),
 	CLK_PCOM("sdac_clk",	SDAC_CLK,	NULL, OFF),
+	CLK_PCOM("sdc_clk",	SDC1_CLK,	NULL, OFF),
+	CLK_PCOM("sdc_pclk",	SDC1_P_CLK,	NULL, OFF),
+	CLK_PCOM("sdc_clk",	SDC2_CLK,	NULL, OFF),
+	CLK_PCOM("sdc_pclk",	SDC2_P_CLK,	NULL, OFF),
+	CLK_PCOM("sdc_clk",	SDC3_CLK,	NULL, OFF),
+	CLK_PCOM("sdc_pclk",	SDC3_P_CLK,	NULL, OFF),
+	CLK_PCOM("sdc_clk",	SDC4_CLK,	NULL, OFF),
+	CLK_PCOM("sdc_pclk",	SDC4_P_CLK,	NULL, OFF),
 	CLK_PCOM("spi_clk",	SPI_CLK,	NULL, 0),
 	CLK_PCOM("tsif_clk",	TSIF_CLK,	NULL, 0),
 	CLK_PCOM("tsif_ref_clk",	TSIF_REF_CLK,	NULL, 0),
 	CLK_PCOM("tv_dac_clk",	TV_DAC_CLK,	NULL, 0),
 	CLK_PCOM("tv_enc_clk",	TV_ENC_CLK,	NULL, 0),
+	CLK_PCOM("uart_clk",	UART1_CLK,	NULL, OFF),
+	CLK_PCOM("uart_clk",	UART2_CLK,	NULL, 0),
 	CLK_PCOM("uart_clk",	UART3_CLK,	&msm_device_uart3.dev, OFF),
+	CLK_PCOM("uartdm_clk",	UART1DM_CLK,	NULL, OFF),
+	CLK_PCOM("uartdm_clk",	UART2DM_CLK,	NULL, 0),
 	CLK_PCOM("usb_hs_clk",	USB_HS_CLK,	NULL, OFF),
 	CLK_PCOM("usb_hs_pclk",	USB_HS_P_CLK,	NULL, OFF),
 	CLK_PCOM("usb_otg_clk",	USB_OTG_CLK,	NULL, 0),
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#5 lore raw

PATCH 5/22 msm: clock-7x30: Add 7x30 local clock driver

In reply to Stephen Boyd

From: Saravana Kannan <[email protected]>

Support locally controllable clocks on the 7x30 target.

---
 arch/arm/mach-msm/Makefile     |    1 +
 arch/arm/mach-msm/clock-7x30.c | 1550 ++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-msm/clock-7x30.h |   38 +-
 arch/arm/mach-msm/clock.c      |   13 +-
 arch/arm/mach-msm/clock.h      |   12 +
 arch/arm/mach-msm/proc_comm.h  |    1 +
 6 files changed, 1599 insertions(+), 16 deletions(-)
 create mode 100644 arch/arm/mach-msm/clock-7x30.c
arch/arm/mach-msm/Makefile +1 -0
index dc8ef08..8588b57 100644
@@ -2,6 +2,7 @@ obj-y += io.o idle.o timer.o
 ifdef CONFIG_MSM_PROC_COMM
 obj-$(CONFIG_DEBUG_FS) += clock-debug.o
 endif
+obj-$(CONFIG_ARCH_MSM7X30) += clock-7x30.o
 ifndef CONFIG_ARCH_MSM8X60
 obj-y += acpuclock-arm11.o
 obj-y += dma.o
arch/arm/mach-msm/clock-7x30.c new file +1550 -0

1,550 lines not on this page · raw message

arch/arm/mach-msm/clock-7x30.h +31 -7
index e16f72f..d41acb7 100644
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009, Code Aurora Forum. All rights reserved.
+/* Copyright (c) 2009-2010, Code Aurora Forum. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -33,6 +33,8 @@
 enum {
 	L_7X30_NONE_CLK = -1,
 	L_7X30_ADM_CLK,
+	L_7X30_ADM_P_CLK,
+	L_7X30_CE_CLK,
 	L_7X30_I2C_CLK,
 	L_7X30_I2C_2_CLK,
 	L_7X30_QUP_I2C_CLK,
@@ -135,17 +137,30 @@ enum {
 	L_7X30_NR_CLKS
 };
 
-struct clk_ops;
-extern struct clk_ops clk_ops_7x30;
-
-struct clk_ops *clk_7x30_is_local(uint32_t id);
-int clk_7x30_init(void);
-
 void pll_enable(uint32_t pll);
 void pll_disable(uint32_t pll);
 
+enum {
+	PLL_0 = 0,
+	PLL_1,
+	PLL_2,
+	PLL_3,
+	PLL_4,
+	PLL_5,
+	PLL_6,
+	NUM_PLL
+};
+
+enum {
+	LOW,
+	NOMINAL,
+	HIGH,
+	MSMC1_END
+};
+
 extern int internal_pwr_rail_ctl_auto(unsigned rail_id, bool enable);
 
+extern struct clk_ops clk_ops_7x30;
 #define CLK_7X30(clk_name, clk_id, clk_dev, clk_flags) {	\
 	.name = clk_name, \
 	.id = L_7X30_##clk_id, \
@@ -164,5 +179,14 @@ extern int internal_pwr_rail_ctl_auto(unsigned rail_id, bool enable);
 	.dbg_name = #l_id, \
 	}
 
+#define CLK_7X30L(clk_name, l_id, clk_dev, clk_flags) {	\
+	.name = clk_name, \
+	.id = L_7X30_##l_id, \
+	.flags = clk_flags, \
+	.dev = clk_dev, \
+	.dbg_name = #l_id, \
+	.ops = &clk_ops_7x30, \
+	}
+
 #endif
 
arch/arm/mach-msm/clock.c +4 -9
index 8c2b4dd..56c7549 100644
@@ -162,21 +162,16 @@ EXPORT_SYMBOL(clk_set_flags);
  */
 static struct clk *ebi1_clk;
 
-static void __init set_clock_ops(struct clk *clk)
-{
-	if (!clk->ops) {
-		clk->ops = &clk_ops_pcom;
-		clk->id = clk->remote_id;
-	}
-}
-
 void __init msm_clock_init(struct clk *clock_tbl, unsigned num_clocks)
 {
 	unsigned n;
 
+	/* Do SoC-speficic clock init operations. */
+	msm_clk_soc_init();
+
 	mutex_lock(&clocks_mutex);
 	for (n = 0; n < num_clocks; n++) {
-		set_clock_ops(&clock_tbl[n]);
+		msm_clk_soc_set_ops(&clock_tbl[n]);
 		list_add_tail(&clock_tbl[n].list, &clocks);
 	}
 	mutex_unlock(&clocks_mutex);
arch/arm/mach-msm/clock.h +12 -0
index 70216b0..4841ab6 100644
@@ -62,6 +62,18 @@ struct clk {
 #define CLK_MAX CLKFLAG_MAX
 #define CLK_MINMAX (CLK_MIN | CLK_MAX)
 
+#ifdef CONFIG_ARCH_MSM7X30
+void __init msm_clk_soc_set_ops(struct clk *clk);
+#else
+static inline void __init msm_clk_soc_set_ops(struct clk *clk) { }
+#endif
+
+#if defined(CONFIG_ARCH_MSM7X30)
+void __init msm_clk_soc_init(void);
+#else
+static inline void __init msm_clk_soc_init(void) { }
+#endif
+
 #ifdef CONFIG_DEBUG_FS
 int __init clock_debug_init(void);
 int __init clock_debug_add(struct clk *clock);
arch/arm/mach-msm/proc_comm.h +1 -0
index 12da4ca..e2f2d5a 100644
@@ -137,6 +137,7 @@ enum {
 	PCOM_CLKCTL_RPC_RAIL_DISABLE,
 	PCOM_CLKCTL_RPC_RAIL_CONTROL,
 	PCOM_CLKCTL_RPC_MIN_MSMC1,
+	PCOM_CLKCTL_RPC_SRC_REQUEST,
 	PCOM_NUM_CMDS,
 };
 
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#6 lore raw

PATCH 6/22 msm: clock-7x30: Update clock table

In reply to Stephen Boyd

Mark clocks with CLK_7X30 to indicate they have the potential to be locally controllable. If it's determined at runtime that these clocks are not locally owned, revert the clocks to proc_comm control. Mark clocks with CLK_PCOM when we know that they can't be locally controlled.

---
 arch/arm/mach-msm/devices-msm7x30.c |  147 ++++++++++++++++++++---------------
 1 files changed, 85 insertions(+), 62 deletions(-)
arch/arm/mach-msm/devices-msm7x30.c +85 -62
index 2816be3..55382c4 100644
@@ -58,78 +58,101 @@ struct platform_device msm_device_smd = {
 };
 
 struct clk msm_clocks_7x30[] = {
-	CLK_PCOM("adm_clk",	ADM_CLK,	NULL, 0),
 	CLK_PCOM("adsp_clk",	ADSP_CLK,	NULL, 0),
 	CLK_PCOM("cam_m_clk",	CAM_M_CLK,	NULL, 0),
 	CLK_PCOM("camif_pad_pclk",	CAMIF_PAD_P_CLK,	NULL, OFF),
-	CLK_PCOM("ce_clk",	CE_CLK,	NULL, 0),
 	CLK_PCOM("codec_ssbi_clk",	CODEC_SSBI_CLK,	NULL, 0),
 	CLK_PCOM("ebi1_clk",	EBI1_CLK,	NULL, CLK_MIN),
 	CLK_PCOM("ecodec_clk",	ECODEC_CLK,	NULL, 0),
-	CLK_PCOM("emdh_clk",	EMDH_CLK,	NULL, OFF | CLK_MINMAX),
-	CLK_PCOM("emdh_pclk",	EMDH_P_CLK,	NULL, OFF),
 	CLK_PCOM("gp_clk",	GP_CLK,		NULL, 0),
-	CLK_PCOM("grp_2d_clk",	GRP_2D_CLK,	NULL, 0),
-	CLK_PCOM("grp_2d_pclk",	GRP_2D_P_CLK,	NULL, 0),
-	CLK_PCOM("grp_clk",	GRP_3D_CLK,	NULL, 0),
-	CLK_PCOM("grp_pclk",	GRP_3D_P_CLK,	NULL, 0),
-	CLK_7X30S("grp_src_clk", GRP_3D_SRC_CLK, GRP_3D_CLK,	NULL, 0),
-	CLK_PCOM("hdmi_clk",	HDMI_CLK,	NULL, 0),
-	CLK_PCOM("imem_clk",	IMEM_CLK,	NULL, OFF),
-	CLK_PCOM("jpeg_clk",	JPEG_CLK,	NULL, OFF),
-	CLK_PCOM("jpeg_pclk",	JPEG_P_CLK,	NULL, OFF),
-	CLK_PCOM("lpa_codec_clk",	LPA_CODEC_CLK,		NULL, 0),
-	CLK_PCOM("lpa_core_clk",	LPA_CORE_CLK,		NULL, 0),
-	CLK_PCOM("lpa_pclk",		LPA_P_CLK,		NULL, 0),
-	CLK_PCOM("mdc_clk",	MDC_CLK,	NULL, 0),
-	CLK_PCOM("mddi_clk",	PMDH_CLK,	NULL, OFF | CLK_MINMAX),
-	CLK_PCOM("mddi_pclk",	PMDH_P_CLK,	NULL, 0),
-	CLK_PCOM("mdp_clk",	MDP_CLK,	NULL, OFF),
-	CLK_PCOM("mdp_pclk",	MDP_P_CLK,	NULL, 0),
-	CLK_PCOM("mdp_lcdc_pclk_clk", MDP_LCDC_PCLK_CLK, NULL, 0),
-	CLK_PCOM("mdp_lcdc_pad_pclk_clk", MDP_LCDC_PAD_PCLK_CLK, NULL, 0),
-	CLK_PCOM("mdp_vsync_clk",	MDP_VSYNC_CLK,  NULL, 0),
-	CLK_PCOM("mfc_clk",		MFC_CLK,		NULL, 0),
-	CLK_PCOM("mfc_div2_clk",	MFC_DIV2_CLK,		NULL, 0),
-	CLK_PCOM("mfc_pclk",		MFC_P_CLK,		NULL, 0),
-	CLK_PCOM("mi2s_m_clk",		MI2S_M_CLK,  		NULL, 0),
-	CLK_PCOM("mi2s_s_clk",		MI2S_S_CLK,  		NULL, 0),
-	CLK_PCOM("mi2s_codec_rx_m_clk",	MI2S_CODEC_RX_M_CLK,  NULL, 0),
-	CLK_PCOM("mi2s_codec_rx_s_clk",	MI2S_CODEC_RX_S_CLK,  NULL, 0),
-	CLK_PCOM("mi2s_codec_tx_m_clk",	MI2S_CODEC_TX_M_CLK,  NULL, 0),
-	CLK_PCOM("mi2s_codec_tx_s_clk",	MI2S_CODEC_TX_S_CLK,  NULL, 0),
-	CLK_PCOM("pbus_clk",	PBUS_CLK,	NULL, CLK_MIN),
-	CLK_PCOM("pcm_clk",	PCM_CLK,	NULL, 0),
-	CLK_PCOM("rotator_clk",	AXI_ROTATOR_CLK,		NULL, 0),
-	CLK_PCOM("rotator_imem_clk",	ROTATOR_IMEM_CLK,	NULL, OFF),
-	CLK_PCOM("rotator_pclk",	ROTATOR_P_CLK,		NULL, OFF),
-	CLK_PCOM("sdac_clk",	SDAC_CLK,	NULL, OFF),
-	CLK_PCOM("spi_clk",	SPI_CLK,	NULL, 0),
-	CLK_PCOM("spi_pclk",	SPI_P_CLK,	NULL, 0),
-	CLK_7X30S("tv_src_clk",	TV_CLK, 	TV_ENC_CLK,	NULL, 0),
-	CLK_PCOM("tv_dac_clk",	TV_DAC_CLK,	NULL, 0),
-	CLK_PCOM("tv_enc_clk",	TV_ENC_CLK,	NULL, 0),
-	CLK_PCOM("uart_clk",	UART2_CLK,	&msm_device_uart2.dev, 0),
-	CLK_PCOM("usb_hs_clk",		USB_HS_CLK,		NULL, OFF),
-	CLK_PCOM("usb_hs_pclk",		USB_HS_P_CLK,		NULL, OFF),
-	CLK_PCOM("usb_hs_core_clk",	USB_HS_CORE_CLK,	NULL, OFF),
-	CLK_PCOM("usb_hs2_clk",		USB_HS2_CLK,		NULL, OFF),
-	CLK_PCOM("usb_hs2_pclk",	USB_HS2_P_CLK,		NULL, OFF),
-	CLK_PCOM("usb_hs2_core_clk",	USB_HS2_CORE_CLK,	NULL, OFF),
-	CLK_PCOM("usb_hs3_clk",		USB_HS3_CLK,		NULL, OFF),
-	CLK_PCOM("usb_hs3_pclk",	USB_HS3_P_CLK,		NULL, OFF),
-	CLK_PCOM("usb_hs3_core_clk",	USB_HS3_CORE_CLK,	NULL, OFF),
+	CLK_PCOM("uart_clk",	UART3_CLK,	NULL, OFF),
+	CLK_PCOM("usb_phy_clk",	USB_PHY_CLK,	NULL, 0),
 	CLK_PCOM("vdc_clk",	VDC_CLK,	NULL, OFF | CLK_MIN),
-	CLK_PCOM("vfe_camif_clk",	VFE_CAMIF_CLK, 	NULL, 0),
-	CLK_PCOM("vfe_clk",	VFE_CLK,	NULL, 0),
-	CLK_PCOM("vfe_mdc_clk",	VFE_MDC_CLK,	NULL, 0),
-	CLK_PCOM("vfe_pclk",	VFE_P_CLK,	NULL, OFF),
-	CLK_PCOM("vpe_clk",	VPE_CLK,	NULL, 0),
+	CLK_PCOM("pbus_clk",	PBUS_CLK,	NULL, CLK_MIN),
+
+	CLK_7X30("adm_clk",	ADM_CLK,	NULL, 0),
+	CLK_7X30L("adm_pclk",   ADM_P_CLK,       NULL, 0),
+	CLK_7X30("cam_m_clk",	CAM_M_CLK,	NULL, 0),
+	CLK_7X30("camif_pad_pclk",	CAMIF_PAD_P_CLK,	NULL, OFF),
+	CLK_7X30("ce_clk",	CE_CLK,		NULL, 0),
+	CLK_7X30("emdh_clk",	EMDH_CLK,	NULL, OFF | CLK_MINMAX),
+	CLK_7X30("emdh_pclk",	EMDH_P_CLK,	NULL, OFF),
+	CLK_7X30("grp_2d_clk",	GRP_2D_CLK,	NULL, 0),
+	CLK_7X30("grp_2d_pclk",	GRP_2D_P_CLK,	NULL, 0),
+	CLK_7X30("grp_clk",	GRP_3D_CLK,	NULL, 0),
+	CLK_7X30("grp_pclk",	GRP_3D_P_CLK,	NULL, 0),
+	CLK_7X30S("grp_src_clk", GRP_3D_SRC_CLK, GRP_3D_CLK,	NULL, 0),
+	CLK_7X30("hdmi_clk",	HDMI_CLK,	NULL, 0),
+	CLK_7X30("i2c_clk",	I2C_CLK,	NULL, 0),
+	CLK_7X30("i2c_clk",	I2C_2_CLK,	NULL, 0),
+	CLK_7X30("imem_clk",	IMEM_CLK,	NULL, OFF),
+	CLK_7X30("jpeg_clk",	JPEG_CLK,	NULL, OFF),
+	CLK_7X30("jpeg_pclk",	JPEG_P_CLK,	NULL, OFF),
+	CLK_7X30("lpa_codec_clk",	LPA_CODEC_CLK,		NULL, 0),
+	CLK_7X30("lpa_core_clk",	LPA_CORE_CLK,		NULL, 0),
+	CLK_7X30("lpa_pclk",		LPA_P_CLK,		NULL, 0),
+	CLK_7X30("mdc_clk",	MDC_CLK,	NULL, 0),
+	CLK_7X30("mddi_clk",	PMDH_CLK,	NULL, OFF | CLK_MINMAX),
+	CLK_7X30("mddi_pclk",	PMDH_P_CLK,	NULL, 0),
+	CLK_7X30("mdp_clk",	MDP_CLK,	NULL, OFF),
+	CLK_7X30("mdp_pclk",	MDP_P_CLK,	NULL, 0),
+	CLK_7X30("mdp_lcdc_pclk_clk", MDP_LCDC_PCLK_CLK, NULL, 0),
+	CLK_7X30("mdp_lcdc_pad_pclk_clk", MDP_LCDC_PAD_PCLK_CLK, NULL, 0),
+	CLK_7X30("mdp_vsync_clk",	MDP_VSYNC_CLK,  NULL, OFF),
+	CLK_7X30("mfc_clk",		MFC_CLK,		NULL, 0),
+	CLK_7X30("mfc_div2_clk",	MFC_DIV2_CLK,		NULL, 0),
+	CLK_7X30("mfc_pclk",		MFC_P_CLK,		NULL, 0),
+	CLK_7X30("mi2s_codec_rx_m_clk",	MI2S_CODEC_RX_M_CLK,  NULL, 0),
+	CLK_7X30("mi2s_codec_rx_s_clk",	MI2S_CODEC_RX_S_CLK,  NULL, 0),
+	CLK_7X30("mi2s_codec_tx_m_clk",	MI2S_CODEC_TX_M_CLK,  NULL, 0),
+	CLK_7X30("mi2s_codec_tx_s_clk",	MI2S_CODEC_TX_S_CLK,  NULL, 0),
+	CLK_7X30("mi2s_m_clk",		MI2S_M_CLK,		NULL, 0),
+	CLK_7X30("mi2s_s_clk",		MI2S_S_CLK,		NULL, 0),
+	CLK_7X30("qup_clk",	QUP_I2C_CLK,	NULL, 0),
+	CLK_7X30("rotator_clk",	AXI_ROTATOR_CLK,		NULL, 0),
+	CLK_7X30("rotator_imem_clk",	ROTATOR_IMEM_CLK,	NULL, OFF),
+	CLK_7X30("rotator_pclk",	ROTATOR_P_CLK,		NULL, OFF),
+	CLK_7X30("sdac_clk",	SDAC_CLK,	NULL, OFF),
+	CLK_7X30("sdc_clk",	SDC1_CLK,	NULL, OFF),
+	CLK_7X30("sdc_pclk",	SDC1_P_CLK,	NULL, OFF),
+	CLK_7X30("sdc_clk",	SDC2_CLK,	NULL, OFF),
+	CLK_7X30("sdc_pclk",	SDC2_P_CLK,	NULL, OFF),
+	CLK_7X30("sdc_clk",	SDC3_CLK,	NULL, OFF),
+	CLK_7X30("sdc_pclk",	SDC3_P_CLK,	NULL, OFF),
+	CLK_7X30("sdc_clk",	SDC4_CLK,	NULL, OFF),
+	CLK_7X30("sdc_pclk",	SDC4_P_CLK,	NULL, OFF),
+	CLK_7X30("spi_clk",	SPI_CLK,	NULL, 0),
+	CLK_7X30("spi_pclk",	SPI_P_CLK,	NULL, 0),
+	CLK_7X30("tsif_ref_clk", TSIF_REF_CLK,	NULL, 0),
+	CLK_7X30("tsif_pclk",	TSIF_P_CLK,	NULL, 0),
+	CLK_7X30("tv_dac_clk",	TV_DAC_CLK,	NULL, 0),
+	CLK_7X30("tv_enc_clk",	TV_ENC_CLK,	NULL, 0),
+	CLK_7X30S("tv_src_clk",	TV_CLK,		TV_ENC_CLK,	NULL, 0),
+	CLK_7X30("uart_clk",	UART1_CLK,	NULL, OFF),
+	CLK_7X30("uart_clk",	UART2_CLK,	&msm_device_uart2.dev, 0),
+	CLK_7X30("uartdm_clk",	UART1DM_CLK,	NULL, OFF),
+	CLK_7X30L("uartdm_pclk", UART1DM_P_CLK,	NULL, 0),
+	CLK_7X30("uartdm_clk",	UART2DM_CLK,	NULL, 0),
+	CLK_7X30L("uartdm_pclk", UART2DM_P_CLK,	NULL, 0),
+	CLK_7X30("usb_hs_clk",		USB_HS_CLK,		NULL, OFF),
+	CLK_7X30("usb_hs_pclk",		USB_HS_P_CLK,		NULL, OFF),
+	CLK_7X30("usb_hs_core_clk",	USB_HS_CORE_CLK,	NULL, OFF),
+	CLK_7X30("usb_hs2_clk",		USB_HS2_CLK,		NULL, OFF),
+	CLK_7X30("usb_hs2_pclk",	USB_HS2_P_CLK,		NULL, OFF),
+	CLK_7X30("usb_hs2_core_clk",	USB_HS2_CORE_CLK,	NULL, OFF),
+	CLK_7X30("usb_hs3_clk",		USB_HS3_CLK,		NULL, OFF),
+	CLK_7X30("usb_hs3_pclk",	USB_HS3_P_CLK,		NULL, OFF),
+	CLK_7X30("usb_hs3_core_clk",	USB_HS3_CORE_CLK,	NULL, OFF),
+	CLK_7X30("vfe_camif_clk",	VFE_CAMIF_CLK, NULL, 0),
+	CLK_7X30("vfe_clk",	VFE_CLK,	NULL, 0),
+	CLK_7X30("vfe_mdc_clk",	VFE_MDC_CLK,	NULL, 0),
+	CLK_7X30("vfe_pclk",	VFE_P_CLK,	NULL, OFF),
+	CLK_7X30("vpe_clk",	VPE_CLK,	NULL, 0),
 
 	/* 7x30 v2 hardware only. */
-	CLK_PCOM("csi_clk",	CSI0_CLK,	NULL, 0),
-	CLK_PCOM("csi_pclk",	CSI0_P_CLK,	NULL, 0),
-	CLK_PCOM("csi_vfe_clk",	CSI0_VFE_CLK,	NULL, 0),
+	CLK_7X30("csi_clk",	CSI0_CLK,	NULL, 0),
+	CLK_7X30("csi_pclk",	CSI0_P_CLK,	NULL, 0),
+	CLK_7X30("csi_vfe_clk",	CSI0_VFE_CLK,	NULL, 0),
 };
 
 unsigned msm_num_clocks_7x30 = ARRAY_SIZE(msm_clocks_7x30);
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#7 lore raw

PATCH 7/22 msm: clock: Refactor clock-7x30 into generic clock-local driver

In reply to Stephen Boyd

From: Matt Wagantall <[email protected]>

The generic 'clock-local' driver is introduced to facilitate sharing of common code among local clock drivers for different SoCs. Presently, only 7x30 makes use of this driver.

SoC-independent code is implemented in clock-local.c, while SoC-specific code is implemented in other clock-* files (ex. clock-7x30.c).

---
 arch/arm/mach-msm/Makefile      |    1 +
 arch/arm/mach-msm/clock-7x30.c  | 1462 +++++++++++++--------------------------
 arch/arm/mach-msm/clock-7x30.h  |  230 +++----
 arch/arm/mach-msm/clock-local.c |  679 ++++++++++++++++++
 arch/arm/mach-msm/clock-local.h |  232 +++++++
 5 files changed, 1516 insertions(+), 1088 deletions(-)
 create mode 100644 arch/arm/mach-msm/clock-local.c
 create mode 100644 arch/arm/mach-msm/clock-local.h
arch/arm/mach-msm/Makefile +1 -0
index 8588b57..33f0c39 100644
@@ -2,6 +2,7 @@ obj-y += io.o idle.o timer.o
 ifdef CONFIG_MSM_PROC_COMM
 obj-$(CONFIG_DEBUG_FS) += clock-debug.o
 endif
+obj-$(CONFIG_ARCH_MSM7X30) += clock-local.o
 obj-$(CONFIG_ARCH_MSM7X30) += clock-7x30.o
 ifndef CONFIG_ARCH_MSM8X60
 obj-y += acpuclock-arm11.o
arch/arm/mach-msm/clock-7x30.c +493 -969

1,743 lines not on this page · raw message

arch/arm/mach-msm/clock-7x30.h +111 -119

267 lines not on this page · raw message

arch/arm/mach-msm/clock-local.c new file +679 -0

679 lines not on this page · raw message

arch/arm/mach-msm/clock-local.h new file +232 -0

232 lines not on this page · raw message

Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#8 lore raw

PATCH 8/22 msm: clock-8x60: Add msm8x60 local clock driver

In reply to Stephen Boyd

From: Matt Wagantall <[email protected]>

Use the clock-local framework to implement the APIs necessary for configuring the msm8x60's peripheral and multimedia clocks.

This includes support for clock gating, managing PLL and XO source requirements, and setting rates. The driver also applies any voltage constraints associated with the frequencies, and provides a means of asserting reset signals for the clock domains.

Tables of discrete frequency levels are used to ensure rates with minimal jitter, power requirements, and interference potential are used whenever possible, though the tables are extensible.

---
 arch/arm/mach-msm/Makefile                      |    2 +
 arch/arm/mach-msm/clock-8x60.c                  | 1802 +++++++++++++++++++++++
 arch/arm/mach-msm/clock-8x60.h                  |  216 +++
 arch/arm/mach-msm/clock-local.h                 |    1 -
 arch/arm/mach-msm/clock.h                       |    2 +-
 arch/arm/mach-msm/include/mach/msm_iomap-8x60.h |   12 +
 arch/arm/mach-msm/io.c                          |    3 +
 7 files changed, 2036 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-msm/clock-8x60.c
 create mode 100644 arch/arm/mach-msm/clock-8x60.h
arch/arm/mach-msm/Makefile +2 -0
index 33f0c39..fa01510 100644
@@ -3,7 +3,9 @@ ifdef CONFIG_MSM_PROC_COMM
 obj-$(CONFIG_DEBUG_FS) += clock-debug.o
 endif
 obj-$(CONFIG_ARCH_MSM7X30) += clock-local.o
+obj-$(CONFIG_ARCH_MSM8X60) += clock-local.o
 obj-$(CONFIG_ARCH_MSM7X30) += clock-7x30.o
+obj-$(CONFIG_ARCH_MSM8X60) += clock-8x60.o
 ifndef CONFIG_ARCH_MSM8X60
 obj-y += acpuclock-arm11.o
 obj-y += dma.o
arch/arm/mach-msm/clock-8x60.c new file +1802 -0

1,802 lines not on this page · raw message

arch/arm/mach-msm/clock-8x60.h new file +216 -0

216 lines not on this page · raw message

arch/arm/mach-msm/clock-local.h +0 -1
index ebefad5..c168985 100644
@@ -97,7 +97,6 @@ struct banked_mnd_masks {
 	}
 #define FREQ_END	(UINT_MAX-1)
 #define F_END	F_RAW(FREQ_END, SRC_NONE, 0, 0, 0, 0, LOW, NULL)
-#define PLL_RATE(l, m, n, v, d) { l, m, n, v, (d>>1) }
 
 /*
  * Generic clock-definition struct and macros
arch/arm/mach-msm/clock.h +1 -1
index 4841ab6..44a6dd6 100644
@@ -68,7 +68,7 @@ void __init msm_clk_soc_set_ops(struct clk *clk);
 static inline void __init msm_clk_soc_set_ops(struct clk *clk) { }
 #endif
 
-#if defined(CONFIG_ARCH_MSM7X30)
+#if defined(CONFIG_ARCH_MSM7X30) || defined(CONFIG_ARCH_MSM8X60)
 void __init msm_clk_soc_init(void);
 #else
 static inline void __init msm_clk_soc_init(void) { }
arch/arm/mach-msm/include/mach/msm_iomap-8x60.h +12 -0
index 7c43a9b..c940596 100644
@@ -55,6 +55,18 @@
 #define MSM_TLMM_PHYS		0x00800000
 #define MSM_TLMM_SIZE		SZ_16K
 
+#define MSM_CLK_CTL_BASE        IOMEM(0xFA010000)
+#define MSM_CLK_CTL_PHYS        0x00900000
+#define MSM_CLK_CTL_SIZE        SZ_16K
+
+#define MSM_MMSS_CLK_CTL_BASE   IOMEM(0xFA014000)
+#define MSM_MMSS_CLK_CTL_PHYS   0x04000000
+#define MSM_MMSS_CLK_CTL_SIZE   SZ_4K
+
+#define MSM_LPASS_CLK_CTL_BASE  IOMEM(0xFA015000)
+#define MSM_LPASS_CLK_CTL_PHYS  0x28000000
+#define MSM_LPASS_CLK_CTL_SIZE  SZ_4K
+
 #define MSM_SHARED_RAM_BASE	IOMEM(0xF0100000)
 #define MSM_SHARED_RAM_SIZE	SZ_1M
 
arch/arm/mach-msm/io.c +3 -0
index f912d7b..d60076a 100644
@@ -107,6 +107,9 @@ static struct map_desc msm8x60_io_desc[] __initdata = {
 	MSM_DEVICE(TMR),
 	MSM_DEVICE(ACC),
 	MSM_DEVICE(GCC),
+	MSM_DEVICE(CLK_CTL),
+	MSM_DEVICE(MMSS_CLK_CTL),
+	MSM_DEVICE(LPASS_CLK_CTL),
 };
 
 void __init msm_map_msm8x60_io(void)
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#9 lore raw

PATCH 9/22 msm: clock: Remove references to clk_ops_pcom

In reply to Stephen Boyd

Not all devices use proc_comm. The soc_clk_set_ops() function was unused. Determining if a clock is local vs. remote is fragile when done by comparing clk_ops pointers. Instead, implement an is_local() function for all clk_ops to determine if the clock is local. Once we do this we can compile clock.c with CONFIG_MSM_PROC_COMM=n.

---
 arch/arm/mach-msm/clock-7x30.c  |    1 +
 arch/arm/mach-msm/clock-8x60.c  |    1 +
 arch/arm/mach-msm/clock-debug.c |    3 +--
 arch/arm/mach-msm/clock-local.c |    5 +++++
 arch/arm/mach-msm/clock-local.h |    1 +
 arch/arm/mach-msm/clock-pcom.c  |    6 ++++++
 arch/arm/mach-msm/clock.c       |    5 -----
 arch/arm/mach-msm/clock.h       |    1 +
 8 files changed, 16 insertions(+), 7 deletions(-)
arch/arm/mach-msm/clock-7x30.c +1 -0
index 0637bee..994104f 100644
@@ -1071,4 +1071,5 @@ struct clk_ops soc_clk_ops_7x30 = {
 	.round_rate = local_clk_round_rate,
 	.reset = pc_clk_reset,
 	.set_flags = soc_clk_set_flags,
+	.is_local = local_clk_is_local,
 };
arch/arm/mach-msm/clock-8x60.c +1 -0
index 5bbc8bb..e1f3c6f 100644
@@ -1799,4 +1799,5 @@ struct clk_ops soc_clk_ops_8x60 = {
 	.round_rate = local_clk_round_rate,
 	.reset = soc_clk_reset,
 	.set_flags = soc_clk_set_flags,
+	.is_local = local_clk_is_local,
 };
arch/arm/mach-msm/clock-debug.c +1 -2
index b67b9e82..4886404 100644
@@ -19,7 +19,6 @@
 #include <linux/debugfs.h>
 #include <linux/clk.h>
 #include "clock.h"
-#include "clock-pcom.h"
 
 static int clock_debug_rate_set(void *data, u64 val)
 {
@@ -79,7 +78,7 @@ static int clock_debug_local_get(void *data, u64 *val)
 {
 	struct clk *clock = data;
 
-	*val = clock->ops != &clk_ops_pcom;
+	*val = clock->ops->is_local(clock->id);
 
 	return 0;
 }
arch/arm/mach-msm/clock-local.c +5 -0
index d6eb6c6..44e0778 100644
@@ -677,3 +677,8 @@ long local_clk_round_rate(unsigned id, unsigned rate)
 
 	return -EPERM;
 }
+
+bool local_clk_is_local(unsigned id)
+{
+	return true;
+}
arch/arm/mach-msm/clock-local.h +1 -0
index c168985..3083369 100644
@@ -211,6 +211,7 @@ int local_clk_set_max_rate(unsigned id, unsigned rate);
 unsigned local_clk_get_rate(unsigned id);
 unsigned local_clk_is_enabled(unsigned id);
 long local_clk_round_rate(unsigned id, unsigned rate);
+bool local_clk_is_local(unsigned id);
 
 /*
  * Required SoC-specific functions, implemented for every supported SoC
arch/arm/mach-msm/clock-pcom.c +6 -0
index 8c4e867..63b7113 100644
@@ -117,6 +117,11 @@ long pc_clk_round_rate(unsigned id, unsigned rate)
 	return rate;
 }
 
+static bool pc_clk_is_local(unsigned id)
+{
+	return false;
+}
+
 struct clk_ops clk_ops_pcom = {
 	.enable = pc_clk_enable,
 	.disable = pc_clk_disable,
@@ -129,4 +134,5 @@ struct clk_ops clk_ops_pcom = {
 	.get_rate = pc_clk_get_rate,
 	.is_enabled = pc_clk_is_enabled,
 	.round_rate = pc_clk_round_rate,
+	.is_local = pc_clk_is_local,
 };
arch/arm/mach-msm/clock.c +0 -5
index 56c7549..06cd313 100644
@@ -21,9 +21,6 @@
 #include <linux/pm_qos_params.h>
 
 #include "clock.h"
-#include "proc_comm.h"
-#include "clock-7x30.h"
-#include "clock-pcom.h"
 
 static DEFINE_MUTEX(clocks_mutex);
 static DEFINE_SPINLOCK(clocks_lock);
@@ -84,8 +81,6 @@ EXPORT_SYMBOL(clk_disable);
 
 int clk_reset(struct clk *clk, enum clk_reset_action action)
 {
-	if (!clk->ops->reset)
-		clk->ops->reset = &pc_clk_reset;
 	return clk->ops->reset(clk->remote_id, action);
 }
 EXPORT_SYMBOL(clk_reset);
arch/arm/mach-msm/clock.h +1 -0
index 44a6dd6..b74ba3e 100644
@@ -43,6 +43,7 @@ struct clk_ops {
 	unsigned (*get_rate)(unsigned id);
 	unsigned (*is_enabled)(unsigned id);
 	long (*round_rate)(unsigned id, unsigned rate);
+	bool (*is_local)(unsigned id);
 };
 
 struct clk {
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#10 lore raw

PATCH 10/22 msm: Move 8x60 to the real clock driver

In reply to Stephen Boyd

The dummy clock driver was added to make 8x60 compile due to proc_comm references in clock.c. Now that those references are gone we can compile the original clock.c with no errors and support clocks on 8x60.

---
 arch/arm/mach-msm/Makefile          |    7 +-
 arch/arm/mach-msm/board-msm8x60.c   |    3 +
 arch/arm/mach-msm/devices-msm8x60.c |  180 +++++++++++++++++++++++++++++++++++
 arch/arm/mach-msm/devices.h         |    3 +
 4 files changed, 189 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/mach-msm/devices-msm8x60.c
arch/arm/mach-msm/Makefile +3 -4
index fa01510..fb44992 100644
@@ -1,7 +1,6 @@
 obj-y += io.o idle.o timer.o
-ifdef CONFIG_MSM_PROC_COMM
+obj-y += clock.o
 obj-$(CONFIG_DEBUG_FS) += clock-debug.o
-endif
 obj-$(CONFIG_ARCH_MSM7X30) += clock-local.o
 obj-$(CONFIG_ARCH_MSM8X60) += clock-local.o
 obj-$(CONFIG_ARCH_MSM7X30) += clock-7x30.o
@@ -19,9 +18,9 @@ obj-y += irq.o
 endif
 endif
 
-obj-$(CONFIG_ARCH_MSM8X60) += clock-dummy.o iommu.o iommu_dev.o devices-msm8x60-iommu.o
+obj-$(CONFIG_ARCH_MSM8X60) += iommu.o iommu_dev.o devices-msm8x60-iommu.o
+obj-$(CONFIG_ARCH_MSM8X60) += devices-msm8x60.o
 obj-$(CONFIG_MSM_PROC_COMM) += proc_comm.o clock-pcom.o vreg.o
-obj-$(CONFIG_MSM_PROC_COMM) += clock.o
 obj-$(CONFIG_ARCH_QSD8X50) += sirc.o
 obj-$(CONFIG_MSM_SMD) += smd.o smd_debug.o
 obj-$(CONFIG_MSM_SMD) += last_radio_log.o
arch/arm/mach-msm/board-msm8x60.c +3 -0
index 852428b..a584d38 100644
@@ -28,6 +28,8 @@
 #include <mach/board.h>
 #include <mach/msm_iomap.h>
 
+#include "devices.h"
+
 void __iomem *gic_cpu_base_addr;
 
 static void __init msm8x60_map_io(void)
@@ -64,6 +66,7 @@ static void __init msm8x60_init_irq(void)
 
 static void __init msm8x60_init(void)
 {
+	msm_clock_init(msm_clocks_8x60, msm_num_clocks_8x60);
 }
 
 MACHINE_START(MSM8X60_RUMI3, "QCT MSM8X60 RUMI3")
arch/arm/mach-msm/devices-msm8x60.c new file +180 -0

180 lines not on this page · raw message

arch/arm/mach-msm/devices.h +3 -0
index 68b8075..81d2b5d8 100644
@@ -48,4 +48,7 @@ extern unsigned msm_num_clocks_7x30;
 extern struct clk msm_clocks_8x50[];
 extern unsigned msm_num_clocks_8x50;
 
+extern struct clk msm_clocks_8x60[];
+extern unsigned msm_num_clocks_8x60;
+
 #endif
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#11 lore raw

PATCH 11/22 msm: clock Add debugfs interface to measure clock rates

In reply to Stephen Boyd

From: Matt Wagantall <[email protected]>

Use the SoC's ring oscillator hardware to measure the clock rate of locally-controlled clocks. This allows for the development of more comprehensive end-to-end clock tests.

A 'measure' debugfs node is created for each clock to perform the measurement and retrieve the result. soc_clk_measure_rate() should *only* be used for debug purposes since it busy-loops while the measurement takes place (~15 ms).

Clock rates are in units of Hz. Clocks that are not locally controlled or do not support rate measurement will return -1.

---
 arch/arm/mach-msm/clock-7x30.c  |   90 ++++++++++++++++++++++++++++++++++
 arch/arm/mach-msm/clock-8x60.c  |  101 +++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-msm/clock-debug.c |   15 ++++++
 arch/arm/mach-msm/clock-pcom.c  |    7 +++
 arch/arm/mach-msm/clock.h       |    1 +
 5 files changed, 214 insertions(+), 0 deletions(-)
arch/arm/mach-msm/clock-7x30.c +90 -0
index 994104f..e13de24 100644
@@ -89,6 +89,10 @@
 #define VPE_NS_REG		REG(0x015C)
 
 /* Registers in the base (non-shadow) region. */
+#define CLK_TEST_BASE_REG	REG_BASE(0x011C)
+#define CLK_TEST_2_BASE_REG	REG_BASE(0x0384)
+#define MISC_CLK_CTL_BASE_REG	REG_BASE(0x0110)
+#define PRPH_WEB_NS_BASE_REG	REG_BASE(0x0080)
 #define PLL0_STATUS_BASE_REG	REG_BASE(0x0318)
 #define PLL1_STATUS_BASE_REG	REG_BASE(0x0334)
 #define PLL2_STATUS_BASE_REG	REG_BASE(0x0350)
@@ -96,12 +100,15 @@
 #define PLL4_STATUS_BASE_REG	REG_BASE(0x0254)
 #define PLL5_STATUS_BASE_REG	REG_BASE(0x0258)
 #define PLL6_STATUS_BASE_REG	REG_BASE(0x04EC)
+#define RINGOSC_CNT_BASE_REG	REG_BASE(0x00FC)
 #define SH2_OWN_APPS1_BASE_REG	REG_BASE(0x040C)
 #define SH2_OWN_APPS2_BASE_REG	REG_BASE(0x0414)
 #define SH2_OWN_APPS3_BASE_REG	REG_BASE(0x0444)
 #define SH2_OWN_GLBL_BASE_REG	REG_BASE(0x0404)
 #define SH2_OWN_ROW1_BASE_REG	REG_BASE(0x041C)
 #define SH2_OWN_ROW2_BASE_REG	REG_BASE(0x0424)
+#define TCXO_CNT_BASE_REG	REG_BASE(0x00F8)
+#define TCXO_CNT_DONE_BASE_REG	REG_BASE(0x00F8)
 
 
 /* MUX source input identifiers. */
@@ -687,6 +694,88 @@ int soc_set_pwr_rail(unsigned id, int enable)
 	return 0;
 }
 
+/* Sample clock for 'tcxo4_ticks' reference clock ticks. */
+static uint32_t run_measurement(unsigned tcxo4_ticks)
+{
+	/* TCXO4_CNT_EN and RINGOSC_CNT_EN register values. */
+	uint32_t reg_val_enable = readl(MISC_CLK_CTL_BASE_REG) | 0x3;
+	uint32_t reg_val_disable = reg_val_enable & ~0x3;
+
+	/* Stop counters and set the TCXO4 counter start value. */
+	writel(reg_val_disable, MISC_CLK_CTL_BASE_REG);
+	writel(tcxo4_ticks, TCXO_CNT_BASE_REG);
+
+	/* Run measurement and wait for completion. */
+	writel(reg_val_enable, MISC_CLK_CTL_BASE_REG);
+	while (readl(TCXO_CNT_DONE_BASE_REG) == 0)
+		cpu_relax();
+
+	/* Stop counters. */
+	writel(reg_val_disable, MISC_CLK_CTL_BASE_REG);
+
+	return readl(RINGOSC_CNT_BASE_REG);
+}
+
+/* Perform a hardware rate measurement for a given clock.
+   FOR DEBUG USE ONLY: Measurements take ~15 ms! */
+signed soc_clk_measure_rate(unsigned id)
+{
+	struct clk_local *t = &soc_clk_local_tbl[id];
+	unsigned long flags;
+	uint32_t regval, prph_web_reg_old;
+	uint64_t raw_count_short, raw_count_full;
+	signed ret;
+
+	if (t->test_vector == 0)
+		return -EPERM;
+
+	spin_lock_irqsave(&local_clock_reg_lock, flags);
+
+	/* Program test vector. */
+	if (t->test_vector <= 0xFF) {
+		/* Select CLK_TEST_2 */
+		writel(0x4D40, CLK_TEST_BASE_REG);
+		writel(t->test_vector, CLK_TEST_2_BASE_REG);
+	} else
+		writel(t->test_vector, CLK_TEST_BASE_REG);
+
+	/* Enable TCXO4 clock branch and root. */
+	prph_web_reg_old = readl(PRPH_WEB_NS_BASE_REG);
+	regval = prph_web_reg_old | B(9) | B(11);
+	local_src_enable(TCXO);
+	writel(regval, PRPH_WEB_NS_BASE_REG);
+
+	/*
+	 * The ring oscillator counter will not reset if the measured clock
+	 * is not running.  To detect this, run a short measurement before
+	 * the full measurement.  If the raw results of the two are the same
+	 * then the clock must be off.
+	 */
+
+	/* Run a short measurement. (~1 ms) */
+	raw_count_short = run_measurement(0x1000);
+	/* Run a full measurement. (~14 ms) */
+	raw_count_full = run_measurement(0x10000);
+
+	/* Disable TCXO4 clock branch and root. */
+	writel(prph_web_reg_old, PRPH_WEB_NS_BASE_REG);
+	local_src_disable(TCXO);
+
+	/* Return 0 if the clock is off. */
+	if (raw_count_full == raw_count_short)
+		ret = 0;
+	else {
+		/* Compute rate in Hz. */
+		raw_count_full = ((raw_count_full * 10) + 15) * 4800000;
+		do_div(raw_count_full, ((0x10000 * 10) + 35));
+		ret = (signed)raw_count_full;
+	}
+
+	spin_unlock_irqrestore(&local_clock_reg_lock, flags);
+
+	return ret;
+}
+
 /* Implementation for clk_set_flags(). */
 int soc_clk_set_flags(unsigned id, unsigned clk_flags)
 {
@@ -1072,4 +1161,5 @@ struct clk_ops soc_clk_ops_7x30 = {
 	.reset = pc_clk_reset,
 	.set_flags = soc_clk_set_flags,
 	.is_local = local_clk_is_local,
+	.measure_rate = soc_clk_measure_rate,
 };
arch/arm/mach-msm/clock-8x60.c +101 -0

111 lines not on this page · raw message

arch/arm/mach-msm/clock-debug.c +15 -0
index 4886404..73ef9cc 100644
@@ -49,6 +49,16 @@ static int clock_debug_rate_get(void *data, u64 *val)
 DEFINE_SIMPLE_ATTRIBUTE(clock_rate_fops, clock_debug_rate_get,
 			clock_debug_rate_set, "%llu\n");
 
+static int clock_debug_measure_get(void *data, u64 *val)
+{
+	struct clk *clock = data;
+	*val = clock->ops->measure_rate(clock->id);
+	return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(clock_measure_fops, clock_debug_measure_get,
+			NULL, "%lld\n");
+
 static int clock_debug_enable_set(void *data, u64 val)
 {
 	struct clk *clock = data;
@@ -123,6 +133,11 @@ int __init clock_debug_add(struct clk *clock)
 	if (!debugfs_create_file("is_local", S_IRUGO, clk_dir, clock,
 				&clock_local_fops))
 		goto error;
+
+	if (!debugfs_create_file("measure", S_IRUGO, clk_dir,
+				clock, &clock_measure_fops))
+		goto error;
+
 	return 0;
 error:
 	debugfs_remove_recursive(clk_dir);
arch/arm/mach-msm/clock-pcom.c +7 -0
index 63b7113..2f9d0d4 100644
@@ -102,6 +102,12 @@ unsigned pc_clk_get_rate(unsigned id)
 		return id;
 }
 
+int pc_clk_measure_rate(unsigned id)
+{
+	/* Not supported. */
+	return -EPERM;
+}
+
 unsigned pc_clk_is_enabled(unsigned id)
 {
 	if (msm_proc_comm(PCOM_CLKCTL_RPC_ENABLED, &id, NULL))
@@ -132,6 +138,7 @@ struct clk_ops clk_ops_pcom = {
 	.set_max_rate = pc_clk_set_max_rate,
 	.set_flags = pc_clk_set_flags,
 	.get_rate = pc_clk_get_rate,
+	.measure_rate = pc_clk_measure_rate,
 	.is_enabled = pc_clk_is_enabled,
 	.round_rate = pc_clk_round_rate,
 	.is_local = pc_clk_is_local,
arch/arm/mach-msm/clock.h +1 -0
index b74ba3e..f09e01b 100644
@@ -41,6 +41,7 @@ struct clk_ops {
 	int (*set_max_rate)(unsigned id, unsigned rate);
 	int (*set_flags)(unsigned id, unsigned flags);
 	unsigned (*get_rate)(unsigned id);
+	int (*measure_rate)(unsigned id);
 	unsigned (*is_enabled)(unsigned id);
 	long (*round_rate)(unsigned id, unsigned rate);
 	bool (*is_local)(unsigned id);
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#12 lore raw

PATCH 12/22 msm: clock: Add list_rate debugfs nodes for locally-controlled clocks

In reply to Stephen Boyd

From: Matt Wagantall <[email protected]>

Add debugfs nodes to list all of the supported rates for rate-settable locally-controlled clocks. This allows a clock's supported rates to be queried from userspace, and allows more comprehensive userspace clock tests to be developed.

---
 arch/arm/mach-msm/clock-7x30.c  |    1 +
 arch/arm/mach-msm/clock-8x60.c  |    1 +
 arch/arm/mach-msm/clock-debug.c |   31 +++++++++++++++++++++++++++++++
 arch/arm/mach-msm/clock-local.c |   11 +++++++++++
 arch/arm/mach-msm/clock-local.h |    1 +
 arch/arm/mach-msm/clock.h       |    1 +
 6 files changed, 46 insertions(+), 0 deletions(-)
arch/arm/mach-msm/clock-7x30.c +1 -0
index e13de24..9e73d8a 100644
@@ -1156,6 +1156,7 @@ struct clk_ops soc_clk_ops_7x30 = {
 	.set_min_rate = local_clk_set_min_rate,
 	.set_max_rate = local_clk_set_max_rate,
 	.get_rate = local_clk_get_rate,
+	.list_rate = local_clk_list_rate,
 	.is_enabled = local_clk_is_enabled,
 	.round_rate = local_clk_round_rate,
 	.reset = pc_clk_reset,
arch/arm/mach-msm/clock-8x60.c +1 -0
index 6972001..28017b7 100644
@@ -1895,6 +1895,7 @@ struct clk_ops soc_clk_ops_8x60 = {
 	.set_min_rate = local_clk_set_min_rate,
 	.set_max_rate = local_clk_set_max_rate,
 	.get_rate = local_clk_get_rate,
+	.list_rate = local_clk_list_rate,
 	.is_enabled = local_clk_is_enabled,
 	.round_rate = local_clk_round_rate,
 	.reset = soc_clk_reset,
arch/arm/mach-msm/clock-debug.c +31 -0
index 73ef9cc..354bc1e 100644
@@ -17,6 +17,7 @@
 #include <linux/module.h>
 #include <linux/ctype.h>
 #include <linux/debugfs.h>
+#include <linux/seq_file.h>
 #include <linux/clk.h>
 #include "clock.h"
 
@@ -106,6 +107,32 @@ int __init clock_debug_init(void)
 	return 0;
 }
 
+static int list_rates_show(struct seq_file *m, void *unused)
+{
+	struct clk *clock = m->private;
+	int rate, i = 0;
+
+	if (clock->ops->list_rate == NULL)
+		return -EINVAL;
+
+	while ((rate = clock->ops->list_rate(clock->id, i++)) >= 0)
+		seq_printf(m, "%d\n", rate);
+
+	return 0;
+}
+
+static int list_rates_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, list_rates_show, inode->i_private);
+}
+
+static const struct file_operations list_rates_fops = {
+	.open		= list_rates_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= seq_release,
+};
+
 int __init clock_debug_add(struct clk *clock)
 {
 	char temp[50], *ptr;
@@ -138,6 +165,10 @@ int __init clock_debug_add(struct clk *clock)
 				clock, &clock_measure_fops))
 		goto error;
 
+	if (!debugfs_create_file("list_rates", S_IRUGO, clk_dir,
+				clock, &list_rates_fops))
+		goto error;
+
 	return 0;
 error:
 	debugfs_remove_recursive(clk_dir);
arch/arm/mach-msm/clock-local.c +11 -0
index 44e0778..f80efa6 100644
@@ -682,3 +682,14 @@ bool local_clk_is_local(unsigned id)
 {
 	return true;
 }
+
+/* Return the nth supported frequency for a given clock. */
+int local_clk_list_rate(unsigned id, unsigned n)
+{
+	struct clk_local *clk = &soc_clk_local_tbl[id];
+
+	if (!clk->freq_tbl || clk->freq_tbl->freq_hz == FREQ_END)
+		return -ENXIO;
+
+	return (clk->freq_tbl + n)->freq_hz;
+}
arch/arm/mach-msm/clock-local.h +1 -0
index 3083369..cf97219 100644
@@ -209,6 +209,7 @@ int local_clk_set_rate(unsigned id, unsigned rate);
 int local_clk_set_min_rate(unsigned id, unsigned rate);
 int local_clk_set_max_rate(unsigned id, unsigned rate);
 unsigned local_clk_get_rate(unsigned id);
+int local_clk_list_rate(unsigned id, unsigned n);
 unsigned local_clk_is_enabled(unsigned id);
 long local_clk_round_rate(unsigned id, unsigned rate);
 bool local_clk_is_local(unsigned id);
arch/arm/mach-msm/clock.h +1 -0
index f09e01b..67f9d9e 100644
@@ -41,6 +41,7 @@ struct clk_ops {
 	int (*set_max_rate)(unsigned id, unsigned rate);
 	int (*set_flags)(unsigned id, unsigned flags);
 	unsigned (*get_rate)(unsigned id);
+	int (*list_rate)(unsigned id, unsigned n);
 	int (*measure_rate)(unsigned id);
 	unsigned (*is_enabled)(unsigned id);
 	long (*round_rate)(unsigned id, unsigned rate);
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#13 lore raw

PATCH 13/22 msm: clock: Push down clock count and locking into sub drivers

In reply to Stephen Boyd

The clock voting code will need to call clk_set_rate() from within a spinlock so we must push down the refcount and lock into each sub driver to avoid recursive locking.

---
 arch/arm/mach-msm/clock-local.c |    3 +-
 arch/arm/mach-msm/clock-pcom.c  |   59 ++++++++++++++++++++++++++++++++++----
 arch/arm/mach-msm/clock.c       |   32 ++------------------
 arch/arm/mach-msm/clock.h       |    1 -
 4 files changed, 58 insertions(+), 37 deletions(-)
arch/arm/mach-msm/clock-local.c +2 -1
index f80efa6..86b5a9d 100644
@@ -501,7 +501,8 @@ void local_clk_auto_off(unsigned id)
 		return;
 
 	spin_lock_irqsave(&local_clock_reg_lock, flags);
-	local_clk_disable_reg(id);
+	if (clk->count == 0)
+		local_clk_disable_reg(id);
 	spin_unlock_irqrestore(&local_clock_reg_lock, flags);
 }
 
arch/arm/mach-msm/clock-pcom.c +52 -7

86 lines not on this page · raw message

arch/arm/mach-msm/clock.c +4 -28
index 06cd313..80e1d64 100644
@@ -23,7 +23,6 @@
 #include "clock.h"
 
 static DEFINE_MUTEX(clocks_mutex);
-static DEFINE_SPINLOCK(clocks_lock);
 static LIST_HEAD(clocks);
 
 /*
@@ -57,25 +56,13 @@ EXPORT_SYMBOL(clk_put);
 
 int clk_enable(struct clk *clk)
 {
-	unsigned long flags;
-	spin_lock_irqsave(&clocks_lock, flags);
-	clk->count++;
-	if (clk->count == 1)
-		clk->ops->enable(clk->id);
-	spin_unlock_irqrestore(&clocks_lock, flags);
-	return 0;
+	return clk->ops->enable(clk->id);
 }
 EXPORT_SYMBOL(clk_enable);
 
 void clk_disable(struct clk *clk)
 {
-	unsigned long flags;
-	spin_lock_irqsave(&clocks_lock, flags);
-	BUG_ON(clk->count == 0);
-	clk->count--;
-	if (clk->count == 0)
-		clk->ops->disable(clk->id);
-	spin_unlock_irqrestore(&clocks_lock, flags);
+	clk->ops->disable(clk->id);
 }
 EXPORT_SYMBOL(clk_disable);
 
@@ -182,27 +169,16 @@ void __init msm_clock_init(struct clk *clock_tbl, unsigned num_clocks)
  */
 static int __init clock_late_init(void)
 {
-	unsigned long flags;
 	struct clk *clk;
-	unsigned count = 0;
 
 	clock_debug_init();
 	mutex_lock(&clocks_mutex);
 	list_for_each_entry(clk, &clocks, list) {
 		clock_debug_add(clk);
-		if (clk->flags & CLKFLAG_AUTO_OFF) {
-			spin_lock_irqsave(&clocks_lock, flags);
-			if (!clk->count) {
-				count++;
-				clk->ops->auto_off(clk->id);
-			}
-			spin_unlock_irqrestore(&clocks_lock, flags);
-		}
+		if (clk->flags & CLKFLAG_AUTO_OFF)
+			clk->ops->auto_off(clk->id);
 	}
 	mutex_unlock(&clocks_mutex);
-	pr_info("clock_late_init() disabled %d unused clocks\n", count);
 	return 0;
 }
-
 late_initcall(clock_late_init);
-
arch/arm/mach-msm/clock.h +0 -1
index 67f9d9e..4dc8853 100644
@@ -51,7 +51,6 @@ struct clk_ops {
 struct clk {
 	uint32_t id;
 	uint32_t remote_id;
-	uint32_t count;
 	uint32_t flags;
 	const char *name;
 	struct clk_ops *ops;
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#14 lore raw

PATCH 14/22 msm: clock: Support clk_set_parent() clk_ops

In reply to Stephen Boyd

Voting clocks are linked to the clock they vote on with a parent pointer. Implement this API for sub drivers which wish to use it.

---
 arch/arm/mach-msm/clock.c |    2 ++
 arch/arm/mach-msm/clock.h |    1 +
 2 files changed, 3 insertions(+), 0 deletions(-)
arch/arm/mach-msm/clock.c +2 -0
index 80e1d64..b6b7e7c 100644
@@ -119,6 +119,8 @@ EXPORT_SYMBOL(clk_set_max_rate);
 
 int clk_set_parent(struct clk *clk, struct clk *parent)
 {
+	if (clk->ops->set_parent)
+		return clk->ops->set_parent(clk->id, parent);
 	return -ENOSYS;
 }
 EXPORT_SYMBOL(clk_set_parent);
arch/arm/mach-msm/clock.h +1 -0
index 4dc8853..1a9fb72 100644
@@ -46,6 +46,7 @@ struct clk_ops {
 	unsigned (*is_enabled)(unsigned id);
 	long (*round_rate)(unsigned id, unsigned rate);
 	bool (*is_local)(unsigned id);
+	int (*set_parent)(unsigned id, struct clk *parent);
 };
 
 struct clk {
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#15 lore raw

PATCH 15/22 msm: clock-pcom: Add pbus specific clock ops

In reply to Stephen Boyd

The pbus clock always runs at half the ebi1 clock frequency. Since ebi1 clock votes are dropped when the application processor is power collapsed, the ebi1 clock is reserved for the acpuclock driver. Other drivers which have ebi1 clock requirements that are independent of application processor power status use the pbus. To keep this change transparent across drivers and SoCs, add new ops that divides the rate by 2 before sending the request to the modem.

---
 arch/arm/mach-msm/clock-pcom.c      |   29 +++++++++++++++++++++++++++++
 arch/arm/mach-msm/clock-pcom.h      |    1 +
 arch/arm/mach-msm/devices-msm7x30.c |    9 ++++++++-
 3 files changed, 38 insertions(+), 1 deletions(-)
arch/arm/mach-msm/clock-pcom.c +29 -0
index 358e065..4616bbc 100644
@@ -188,3 +188,32 @@ struct clk_ops clk_ops_pcom = {
 	.round_rate = pc_clk_round_rate,
 	.is_local = pc_clk_is_local,
 };
+
+int pc_clk_set_rate2(unsigned id, unsigned rate)
+{
+	return pc_clk_set_rate(id, rate / 2);
+}
+
+int pc_clk_set_min_rate2(unsigned id, unsigned rate)
+{
+	return pc_clk_set_min_rate(id, rate / 2);
+}
+
+unsigned pc_clk_get_rate2(unsigned id)
+{
+	return pc_clk_get_rate(id) * 2;
+}
+
+struct clk_ops clk_ops_pcom_div2 = {
+	.enable = pc_clk_enable,
+	.disable = pc_clk_disable,
+	.reset = pc_clk_reset,
+	.set_rate = pc_clk_set_rate2,
+	.set_min_rate = pc_clk_set_min_rate2,
+	.set_flags = pc_clk_set_flags,
+	.get_rate = pc_clk_get_rate2,
+	.measure_rate = pc_clk_measure_rate,
+	.is_enabled = pc_clk_is_enabled,
+	.round_rate = pc_clk_round_rate,
+	.is_local = pc_clk_is_local,
+};
arch/arm/mach-msm/clock-pcom.h +1 -0
index 2c813f1..e2bca82 100644
@@ -139,6 +139,7 @@
 
 struct clk_ops;
 extern struct clk_ops clk_ops_pcom;
+extern struct clk_ops clk_ops_pcom_div2;
 
 int pc_clk_reset(unsigned id, enum clk_reset_action action);
 
arch/arm/mach-msm/devices-msm7x30.c +8 -1
index 55382c4..72da7cc 100644
@@ -68,7 +68,14 @@ struct clk msm_clocks_7x30[] = {
 	CLK_PCOM("uart_clk",	UART3_CLK,	NULL, OFF),
 	CLK_PCOM("usb_phy_clk",	USB_PHY_CLK,	NULL, 0),
 	CLK_PCOM("vdc_clk",	VDC_CLK,	NULL, OFF | CLK_MIN),
-	CLK_PCOM("pbus_clk",	PBUS_CLK,	NULL, CLK_MIN),
+	{
+		.name = "pbus_clk",
+		.id = P_PBUS_CLK,
+		.remote_id = P_PBUS_CLK,
+		.ops = &clk_ops_pcom_div2,
+		.flags = CLK_MIN,
+		.dbg_name = "pbus_clk",
+	},
 
 	CLK_7X30("adm_clk",	ADM_CLK,	NULL, 0),
 	CLK_7X30L("adm_pclk",   ADM_P_CLK,       NULL, 0),
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#16 lore raw

PATCH 16/22 msm: clock: Implement rate voting

In reply to Stephen Boyd

Some clocks have multiple consumers where each consumer requires a minimum rate. Implement a sub driver to aggregate clk_set_rate() calls from each consumer and call clk_set_rate() on the parent clock when the minimum requested rate of all the voters changes.

---
 arch/arm/mach-msm/Makefile      |    2 +-
 arch/arm/mach-msm/clock-voter.c |  202 +++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-msm/clock-voter.h |   52 ++++++++++
 arch/arm/mach-msm/clock.h       |    3 +
 4 files changed, 258 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-msm/clock-voter.c
 create mode 100644 arch/arm/mach-msm/clock-voter.h
arch/arm/mach-msm/Makefile +1 -1
index fb44992..56651b4 100644
@@ -1,5 +1,5 @@
 obj-y += io.o idle.o timer.o
-obj-y += clock.o
+obj-y += clock.o clock-voter.o
 obj-$(CONFIG_DEBUG_FS) += clock-debug.o
 obj-$(CONFIG_ARCH_MSM7X30) += clock-local.o
 obj-$(CONFIG_ARCH_MSM8X60) += clock-local.o
arch/arm/mach-msm/clock-voter.c new file +202 -0

202 lines not on this page · raw message

arch/arm/mach-msm/clock-voter.h new file +52 -0

52 lines not on this page · raw message

arch/arm/mach-msm/clock.h +3 -0
index 1a9fb72..9278c03 100644
@@ -25,6 +25,7 @@
 #define CLKFLAG_NOINVERT		0x00000002
 #define CLKFLAG_NONEST			0x00000004
 #define CLKFLAG_NORESET			0x00000008
+#define CLKFLAG_HANDLE			0x00000010
 
 #define CLK_FIRST_AVAILABLE_FLAG	0x00000100
 #define CLKFLAG_AUTO_OFF		0x00000200
@@ -58,6 +59,8 @@ struct clk {
 	const char *dbg_name;
 	struct list_head list;
 	struct device *dev;
+	struct hlist_head voters;
+	const char *aggregator;
 };
 
 #define OFF CLKFLAG_AUTO_OFF
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#17 lore raw

PATCH 17/22 msm: Migrate to clock rate voting

In reply to Stephen Boyd

Add the appropriate clock voters and integrate clock.c with the voting driver so that voting works appropriately.

---
 arch/arm/mach-msm/clock.c           |   23 +++++++++++++----------
 arch/arm/mach-msm/devices-msm7x30.c |   10 ++++++++++
 arch/arm/mach-msm/devices-qsd8x50.c |    9 +++++++++
 3 files changed, 32 insertions(+), 10 deletions(-)
arch/arm/mach-msm/clock.c +13 -10
index b6b7e7c..c505e30 100644
@@ -18,7 +18,10 @@
 #include <linux/list.h>
 #include <linux/err.h>
 #include <linux/spinlock.h>
-#include <linux/pm_qos_params.h>
+#include <linux/mutex.h>
+#include <linux/clk.h>
+#include <linux/string.h>
+#include <linux/module.h>
 
 #include "clock.h"
 
@@ -139,16 +142,10 @@ int clk_set_flags(struct clk *clk, unsigned long flags)
 }
 EXPORT_SYMBOL(clk_set_flags);
 
-/* EBI1 is the only shared clock that several clients want to vote on as of
- * this commit. If this changes in the future, then it might be better to
- * make clk_min_rate handle the voting or make ebi1_clk_set_min_rate more
- * generic to support different clocks.
- */
-static struct clk *ebi1_clk;
-
 void __init msm_clock_init(struct clk *clock_tbl, unsigned num_clocks)
 {
 	unsigned n;
+	struct clk *clk;
 
 	/* Do SoC-speficic clock init operations. */
 	msm_clk_soc_init();
@@ -160,9 +157,15 @@ void __init msm_clock_init(struct clk *clock_tbl, unsigned num_clocks)
 	}
 	mutex_unlock(&clocks_mutex);
 
-	ebi1_clk = clk_get(NULL, "ebi1_clk");
-	BUG_ON(ebi1_clk == NULL);
+	for (n = 0; n < num_clocks; n++) {
+		clk = &clock_tbl[n];
+		if (clk->flags & CLKFLAG_HANDLE) {
+			struct clk *agg_clk = clk_get(NULL, clk->aggregator);
+			BUG_ON(IS_ERR(agg_clk));
 
+			clk_set_parent(clk, agg_clk);
+		}
+	}
 }
 
 /* The bootloader and/or AMSS may have left various clocks enabled.
arch/arm/mach-msm/devices-msm7x30.c +10 -0
index 72da7cc..f18d86b 100644
@@ -23,6 +23,7 @@
 #include <mach/board.h>
 
 #include "devices.h"
+#include "clock-voter.h"
 #include "smd_private.h"
 
 #include <asm/mach/flash.h>
@@ -156,6 +157,15 @@ struct clk msm_clocks_7x30[] = {
 	CLK_7X30("vfe_pclk",	VFE_P_CLK,	NULL, OFF),
 	CLK_7X30("vpe_clk",	VPE_CLK,	NULL, 0),
 
+	CLK_VOTER("ebi1_dtv_clk", EBI_DTV, "pbus_clk", NULL, 0),
+	CLK_VOTER("ebi1_kgsl_clk", EBI_KGSL, "pbus_clk", NULL, 0),
+	CLK_VOTER("ebi1_lcdc_clk", EBI_LCDC, "pbus_clk", NULL, 0),
+	CLK_VOTER("ebi1_mddi_clk", EBI_MDDI, "pbus_clk", NULL, 0),
+	CLK_VOTER("ebi1_tv_clk", EBI_TV, "pbus_clk", NULL, 0),
+	CLK_VOTER("ebi1_usb_clk", EBI_USB, "pbus_clk", NULL, 0),
+	CLK_VOTER("ebi1_vcd_clk", EBI_VCD, "pbus_clk", NULL, 0),
+	CLK_VOTER("ebi1_vfe_clk", EBI_VFE, "pbus_clk", NULL, 0),
+
 	/* 7x30 v2 hardware only. */
 	CLK_7X30("csi_clk",	CSI0_CLK,	NULL, 0),
 	CLK_7X30("csi_pclk",	CSI0_P_CLK,	NULL, 0),
arch/arm/mach-msm/devices-qsd8x50.c +9 -0
index 271c8bb..3b11d28 100644
@@ -28,6 +28,7 @@
 
 #include <mach/mmc.h>
 #include "clock-pcom.h"
+#include "clock-voter.h"
 
 static struct resource resources_uart3[] = {
 	{
@@ -106,6 +107,14 @@ struct clk msm_clocks_8x50[] = {
 	CLK_PCOM("usb_hs3_clk",	USB_HS3_CLK,	NULL, OFF),
 	CLK_PCOM("usb_hs3_pclk",	USB_HS3_P_CLK,	NULL, OFF),
 	CLK_PCOM("usb_phy_clk",	USB_PHY_CLK,	NULL, 0),
+
+	CLK_VOTER("ebi1_acpu_clk", EBI_ACPU, "ebi1_clk", NULL, 0),
+	CLK_VOTER("ebi1_kgsl_clk", EBI_KGSL, "ebi1_clk", NULL, 0),
+	CLK_VOTER("ebi1_lcdc_clk", EBI_LCDC, "ebi1_clk", NULL, 0),
+	CLK_VOTER("ebi1_mddi_clk", EBI_MDDI, "ebi1_clk", NULL, 0),
+	CLK_VOTER("ebi1_tv_clk", EBI_TV, "ebi1_clk", NULL, 0),
+	CLK_VOTER("ebi1_usb_clk", EBI_USB, "ebi1_clk", NULL, 0),
+	CLK_VOTER("ebi1_vfe_clk", EBI_VFE, "ebi1_clk", NULL, 0),
 };
 
 unsigned msm_num_clocks_8x50 = ARRAY_SIZE(msm_clocks_8x50);
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#18 lore raw

PATCH 18/22 msm: clock: Migrate to clkdev

In reply to Stephen Boyd

Migrating to clkdev has several advantages:

* Less code in mach-msm/clock.c

* A more robust clk_get() implementation

* clk_add_alias() support

* clk_get_sys() support

In general, this will help board authors setup clock aliases and break the dependency on device pointers in the clock tables.

---
 arch/arm/Kconfig                        |    1 +
 arch/arm/mach-msm/clock-7x30.h          |   43 +++++++++++++++++-------------
 arch/arm/mach-msm/clock-8x60.h          |   16 ++++++-----
 arch/arm/mach-msm/clock-pcom.h          |   16 ++++++-----
 arch/arm/mach-msm/clock-voter.h         |   16 ++++++-----
 arch/arm/mach-msm/clock.c               |   37 +++++---------------------
 arch/arm/mach-msm/clock.h               |    2 +-
 arch/arm/mach-msm/devices-msm7x00.c     |   32 +++++++++++-----------
 arch/arm/mach-msm/devices-msm7x30.c     |   21 +++++++++------
 arch/arm/mach-msm/devices-msm8x60.c     |   19 ++++++++------
 arch/arm/mach-msm/devices-qsd8x50.c     |    5 ++-
 arch/arm/mach-msm/devices.h             |    8 +++---
 arch/arm/mach-msm/include/mach/board.h  |    4 ++-
 arch/arm/mach-msm/include/mach/clkdev.h |   23 ++++++++++++++++
 14 files changed, 133 insertions(+), 110 deletions(-)
 create mode 100644 arch/arm/mach-msm/include/mach/clkdev.h
arch/arm/Kconfig +1 -0
index a19a526..fe25326 100644
@@ -598,6 +598,7 @@ config ARCH_MSM
 	select HAVE_CLK
 	select GENERIC_CLOCKEVENTS
 	select ARCH_REQUIRE_GPIOLIB
+	select COMMON_CLKDEV
 	help
 	  Support for Qualcomm MSM/QSD based systems.  This runs on the
 	  apps processor of the MSM/QSD and depends on a shared memory
arch/arm/mach-msm/clock-7x30.h +24 -19

55 lines not on this page · raw message

arch/arm/mach-msm/clock-8x60.h +9 -7
index 2019add..c6e2244 100644
@@ -203,13 +203,15 @@ struct pll_rate {
 
 extern struct clk_ops soc_clk_ops_8x60;
 #define CLK_8X60(clk_name, clk_id, clk_dev, clk_flags) {	\
-	.name = clk_name, \
-	.id = L_##clk_id, \
-	.remote_id = L_##clk_id, \
-	.ops = &soc_clk_ops_8x60, \
-	.flags = clk_flags, \
-	.dev = clk_dev, \
-	.dbg_name = #clk_id, \
+	.con_id = clk_name, \
+	.dev_id = clk_dev, \
+	.clk = &(struct clk){ \
+		.id = L_##clk_id, \
+		.remote_id = L_##clk_id, \
+		.ops = &soc_clk_ops_8x60, \
+		.flags = clk_flags, \
+		.dbg_name = #clk_id, \
+	}, \
 	}
 
 #endif
arch/arm/mach-msm/clock-pcom.h +9 -7
index e2bca82..ef07632 100644
@@ -144,13 +144,15 @@ extern struct clk_ops clk_ops_pcom_div2;
 int pc_clk_reset(unsigned id, enum clk_reset_action action);
 
 #define CLK_PCOM(clk_name, clk_id, clk_dev, clk_flags) {	\
-	.name = clk_name, \
-	.id = P_##clk_id, \
-	.remote_id = P_##clk_id, \
-	.ops = &clk_ops_pcom, \
-	.flags = clk_flags, \
-	.dev = clk_dev, \
-	.dbg_name = #clk_id, \
+	.con_id = clk_name, \
+	.dev_id = clk_dev, \
+	.clk = &(struct clk){ \
+		.id = P_##clk_id, \
+		.remote_id = P_##clk_id, \
+		.ops = &clk_ops_pcom, \
+		.flags = clk_flags, \
+		.dbg_name = #clk_id, \
+	}, \
 	}
 
 #endif
arch/arm/mach-msm/clock-voter.h +9 -7
index 84bc0b3..d62e35d 100644
@@ -40,13 +40,15 @@ struct clk_ops;
 extern struct clk_ops clk_ops_voter;
 
 #define CLK_VOTER(clk_name, clk_id, agg_name, clk_dev, clk_flags) {	\
-	.name = clk_name, \
-	.id = V_##clk_id, \
-	.flags = clk_flags | CLKFLAG_HANDLE, \
-	.dev = clk_dev, \
-	.aggregator = agg_name, \
-	.dbg_name = clk_name, \
-	.ops = &clk_ops_voter, \
+	.con_id = clk_name, \
+	.dev_id = clk_dev, \
+	.clk = &(struct clk){ \
+		.id = V_##clk_id, \
+		.flags = clk_flags | CLKFLAG_HANDLE, \
+		.aggregator = agg_name, \
+		.dbg_name = clk_name, \
+		.ops = &clk_ops_voter, \
+	}, \
 	}
 
 #endif
arch/arm/mach-msm/clock.c +7 -30
index c505e30..ca2805a 100644
@@ -23,6 +23,8 @@
 #include <linux/string.h>
 #include <linux/module.h>
 
+#include <asm/clkdev.h>
+
 #include "clock.h"
 
 static DEFINE_MUTEX(clocks_mutex);
@@ -31,32 +33,6 @@ static LIST_HEAD(clocks);
 /*
  * Standard clock functions defined in include/linux/clk.h
  */
-struct clk *clk_get(struct device *dev, const char *id)
-{
-	struct clk *clk;
-
-	mutex_lock(&clocks_mutex);
-
-	list_for_each_entry(clk, &clocks, list)
-		if (!strcmp(id, clk->name) && clk->dev == dev)
-			goto found_it;
-
-	list_for_each_entry(clk, &clocks, list)
-		if (!strcmp(id, clk->name) && clk->dev == NULL)
-			goto found_it;
-
-	clk = ERR_PTR(-ENOENT);
-found_it:
-	mutex_unlock(&clocks_mutex);
-	return clk;
-}
-EXPORT_SYMBOL(clk_get);
-
-void clk_put(struct clk *clk)
-{
-}
-EXPORT_SYMBOL(clk_put);
-
 int clk_enable(struct clk *clk)
 {
 	return clk->ops->enable(clk->id);
@@ -142,7 +118,7 @@ int clk_set_flags(struct clk *clk, unsigned long flags)
 }
 EXPORT_SYMBOL(clk_set_flags);
 
-void __init msm_clock_init(struct clk *clock_tbl, unsigned num_clocks)
+void __init msm_clock_init(struct clk_lookup *clock_tbl, unsigned num_clocks)
 {
 	unsigned n;
 	struct clk *clk;
@@ -152,13 +128,14 @@ void __init msm_clock_init(struct clk *clock_tbl, unsigned num_clocks)
 
 	mutex_lock(&clocks_mutex);
 	for (n = 0; n < num_clocks; n++) {
-		msm_clk_soc_set_ops(&clock_tbl[n]);
-		list_add_tail(&clock_tbl[n].list, &clocks);
+		msm_clk_soc_set_ops(clock_tbl[n].clk);
+		clkdev_add(&clock_tbl[n]);
+		list_add_tail(&clock_tbl[n].clk->list, &clocks);
 	}
 	mutex_unlock(&clocks_mutex);
 
 	for (n = 0; n < num_clocks; n++) {
-		clk = &clock_tbl[n];
+		clk = clock_tbl[n].clk;
 		if (clk->flags & CLKFLAG_HANDLE) {
 			struct clk *agg_clk = clk_get(NULL, clk->aggregator);
 			BUG_ON(IS_ERR(agg_clk));
arch/arm/mach-msm/clock.h +1 -1
index 9278c03..c7449a5 100644
@@ -18,6 +18,7 @@
 #define __ARCH_ARM_MACH_MSM_CLOCK_H
 
 #include <linux/init.h>
+#include <linux/types.h>
 #include <linux/list.h>
 #include <mach/clk.h>
 
@@ -54,7 +55,6 @@ struct clk {
 	uint32_t id;
 	uint32_t remote_id;
 	uint32_t flags;
-	const char *name;
 	struct clk_ops *ops;
 	const char *dbg_name;
 	struct list_head list;
arch/arm/mach-msm/devices-msm7x00.c +16 -16
index fb548a8..c3f7c06 100644
@@ -18,13 +18,13 @@
 
 #include <mach/irqs.h>
 #include <mach/msm_iomap.h>
+#include <asm/clkdev.h>
 #include "devices.h"
 
 #include <asm/mach/flash.h>
 #include <linux/mtd/nand.h>
 #include <linux/mtd/partitions.h>
 
-
 #include "clock.h"
 #include <mach/mmc.h>
 
@@ -414,7 +414,7 @@ struct platform_device msm_device_mdp = {
 	.resource = resources_mdp,
 };
 
-struct clk msm_clocks_7x01a[] = {
+struct clk_lookup msm_clocks_7x01a[] = {
 	CLK_PCOM("adm_clk",	ADM_CLK,	NULL, 0),
 	CLK_PCOM("adsp_clk",	ADSP_CLK,	NULL, 0),
 	CLK_PCOM("ebi1_clk",	EBI1_CLK,	NULL, 0),
@@ -423,7 +423,7 @@ struct clk msm_clocks_7x01a[] = {
 	CLK_PCOM("emdh_clk",	EMDH_CLK,	NULL, OFF),
 	CLK_PCOM("gp_clk",		GP_CLK,		NULL, 0),
 	CLK_PCOM("grp_clk",	GRP_3D_CLK,	NULL, OFF),
-	CLK_PCOM("i2c_clk",	I2C_CLK,	&msm_device_i2c.dev, 0),
+	CLK_PCOM("i2c_clk",	I2C_CLK,	"msm_i2c.0", 0),
 	CLK_PCOM("icodec_rx_clk",	ICODEC_RX_CLK,	NULL, 0),
 	CLK_PCOM("icodec_tx_clk",	ICODEC_TX_CLK,	NULL, 0),
 	CLK_PCOM("imem_clk",	IMEM_CLK,	NULL, OFF),
@@ -433,25 +433,25 @@ struct clk msm_clocks_7x01a[] = {
 	CLK_PCOM("pcm_clk",	PCM_CLK,	NULL, 0),
 	CLK_PCOM("mddi_clk",	PMDH_CLK,	NULL, OFF | CLK_MINMAX),
 	CLK_PCOM("sdac_clk",	SDAC_CLK,	NULL, OFF),
-	CLK_PCOM("sdc_clk",	SDC1_CLK,	&msm_device_sdc1.dev, OFF),
-	CLK_PCOM("sdc_pclk",	SDC1_P_CLK,	&msm_device_sdc1.dev, OFF),
-	CLK_PCOM("sdc_clk",	SDC2_CLK,	&msm_device_sdc2.dev, OFF),
-	CLK_PCOM("sdc_pclk",	SDC2_P_CLK,	&msm_device_sdc2.dev, OFF),
-	CLK_PCOM("sdc_clk",	SDC3_CLK,	&msm_device_sdc3.dev, OFF),
-	CLK_PCOM("sdc_pclk",	SDC3_P_CLK,	&msm_device_sdc3.dev, OFF),
-	CLK_PCOM("sdc_clk",	SDC4_CLK,	&msm_device_sdc4.dev, OFF),
-	CLK_PCOM("sdc_pclk",	SDC4_P_CLK,	&msm_device_sdc4.dev, OFF),
+	CLK_PCOM("sdc_clk",	SDC1_CLK,	"msm_sdcc.1", OFF),
+	CLK_PCOM("sdc_pclk",	SDC1_P_CLK,	"msm_sdcc.1", OFF),
+	CLK_PCOM("sdc_clk",	SDC2_CLK,	"msm_sdcc.2", OFF),
+	CLK_PCOM("sdc_pclk",	SDC2_P_CLK,	"msm_sdcc.2", OFF),
+	CLK_PCOM("sdc_clk",	SDC3_CLK,	"msm_sdcc.3", OFF),
+	CLK_PCOM("sdc_pclk",	SDC3_P_CLK,	"msm_sdcc.3", OFF),
+	CLK_PCOM("sdc_clk",	SDC4_CLK,	"msm_sdcc.4", OFF),
+	CLK_PCOM("sdc_pclk",	SDC4_P_CLK,	"msm_sdcc.4", OFF),
 	CLK_PCOM("tsif_clk",	TSIF_CLK,	NULL, 0),
 	CLK_PCOM("tsif_ref_clk",	TSIF_REF_CLK,	NULL, 0),
 	CLK_PCOM("tv_dac_clk",	TV_DAC_CLK,	NULL, 0),
 	CLK_PCOM("tv_enc_clk",	TV_ENC_CLK,	NULL, 0),
-	CLK_PCOM("uart_clk",	UART1_CLK,	&msm_device_uart1.dev, OFF),
-	CLK_PCOM("uart_clk",	UART2_CLK,	&msm_device_uart2.dev, 0),
-	CLK_PCOM("uart_clk",	UART3_CLK,	&msm_device_uart3.dev, OFF),
+	CLK_PCOM("uart_clk",	UART1_CLK,	"msm_serial.0", OFF),
+	CLK_PCOM("uart_clk",	UART2_CLK,	"msm_serial.1", 0),
+	CLK_PCOM("uart_clk",	UART3_CLK,	"msm_serial.2", OFF),
 	CLK_PCOM("uart1dm_clk",	UART1DM_CLK,	NULL, OFF),
 	CLK_PCOM("uart2dm_clk",	UART2DM_CLK,	NULL, 0),
-	CLK_PCOM("usb_hs_clk",	USB_HS_CLK,	&msm_device_hsusb.dev, OFF),
-	CLK_PCOM("usb_hs_pclk",	USB_HS_P_CLK,	&msm_device_hsusb.dev, OFF),
+	CLK_PCOM("usb_hs_clk",	USB_HS_CLK,	"msm_hsusb", OFF),
+	CLK_PCOM("usb_hs_pclk",	USB_HS_P_CLK,	"msm_hsusb", OFF),
 	CLK_PCOM("usb_otg_clk",	USB_OTG_CLK,	NULL, 0),
 	CLK_PCOM("vdc_clk",	VDC_CLK,	NULL, OFF ),
 	CLK_PCOM("vfe_clk",	VFE_CLK,	NULL, OFF),
arch/arm/mach-msm/devices-msm7x30.c +13 -8
index f18d86b..359b427 100644
@@ -17,10 +17,12 @@
 #include <linux/platform_device.h>
 
 #include <linux/dma-mapping.h>
+#include <asm/clkdev.h>
 #include <mach/irqs.h>
 #include <mach/msm_iomap.h>
 #include <mach/dma.h>
 #include <mach/board.h>
+#include <asm/clkdev.h>
 
 #include "devices.h"
 #include "clock-voter.h"
@@ -58,7 +60,8 @@ struct platform_device msm_device_smd = {
 	.id     = -1,
 };
 
-struct clk msm_clocks_7x30[] = {
+struct clk_lookup msm_clocks_7x30[] = {
+	CLK_PCOM("adm_clk",	ADM_CLK,	NULL, 0),
 	CLK_PCOM("adsp_clk",	ADSP_CLK,	NULL, 0),
 	CLK_PCOM("cam_m_clk",	CAM_M_CLK,	NULL, 0),
 	CLK_PCOM("camif_pad_pclk",	CAMIF_PAD_P_CLK,	NULL, OFF),
@@ -70,12 +73,14 @@ struct clk msm_clocks_7x30[] = {
 	CLK_PCOM("usb_phy_clk",	USB_PHY_CLK,	NULL, 0),
 	CLK_PCOM("vdc_clk",	VDC_CLK,	NULL, OFF | CLK_MIN),
 	{
-		.name = "pbus_clk",
-		.id = P_PBUS_CLK,
-		.remote_id = P_PBUS_CLK,
-		.ops = &clk_ops_pcom_div2,
-		.flags = CLK_MIN,
-		.dbg_name = "pbus_clk",
+		.con_id = "pbus_clk",
+		.clk = &(struct clk){
+			.id = P_PBUS_CLK,
+			.remote_id = P_PBUS_CLK,
+			.ops = &clk_ops_pcom_div2,
+			.flags = CLK_MIN,
+			.dbg_name = "pbus_clk",
+		}
 	},
 
 	CLK_7X30("adm_clk",	ADM_CLK,	NULL, 0),
@@ -137,7 +142,7 @@ struct clk msm_clocks_7x30[] = {
 	CLK_7X30("tv_enc_clk",	TV_ENC_CLK,	NULL, 0),
 	CLK_7X30S("tv_src_clk",	TV_CLK,		TV_ENC_CLK,	NULL, 0),
 	CLK_7X30("uart_clk",	UART1_CLK,	NULL, OFF),
-	CLK_7X30("uart_clk",	UART2_CLK,	&msm_device_uart2.dev, 0),
+	CLK_7X30("uart_clk",	UART2_CLK,	"msm_serial.1", 0),
 	CLK_7X30("uartdm_clk",	UART1DM_CLK,	NULL, OFF),
 	CLK_7X30L("uartdm_pclk", UART1DM_P_CLK,	NULL, 0),
 	CLK_7X30("uartdm_clk",	UART2DM_CLK,	NULL, 0),
arch/arm/mach-msm/devices-msm8x60.c +11 -8
index 1f2b189..8842465 100644
@@ -18,11 +18,14 @@
 
 #include <linux/kernel.h>
 #include <linux/clk.h>
+#include <linux/list.h>
+
+#include <asm/clkdev.h>
 
 #include "clock.h"
 #include "clock-8x60.h"
 
-struct clk msm_clocks_8x60[] = {
+struct clk_lookup msm_clocks_8x60[] = {
 	CLK_8X60("ce_clk",		CE2_CLK,		NULL, OFF),
 	CLK_8X60("gsbi_uart_clk",	GSBI1_UART_CLK,		NULL, OFF),
 	CLK_8X60("gsbi_uart_clk",	GSBI2_UART_CLK,		NULL, OFF),
@@ -167,13 +170,13 @@ struct clk msm_clocks_8x60[] = {
 	CLK_8X60("i2s_spkr_osr_clk",	SPARE_I2S_SPKR_OSR_CLK,	NULL, OFF),
 	CLK_8X60("i2s_spkr_bit_clk",	SPARE_I2S_SPKR_BIT_CLK,	NULL, OFF),
 	CLK_8X60("pcm_clk",		PCM_CLK,		NULL, OFF),
-	CLK_8X60("iommu_clk",           JPEGD_AXI_CLK, NULL, 0),
-	CLK_8X60("iommu_clk",           VFE_AXI_CLK, NULL, 0),
-	CLK_8X60("iommu_clk",           VCODEC_AXI_CLK, NULL, 0),
-	CLK_8X60("iommu_clk",           VCODEC_AXI_CLK, NULL, 0),
-	CLK_8X60("iommu_clk",           GFX3D_CLK, NULL, 0),
-	CLK_8X60("iommu_clk",           GFX2D0_CLK, NULL, 0),
-	CLK_8X60("iommu_clk",           GFX2D1_CLK, NULL, 0),
+	CLK_8X60("iommu_clk",           JPEGD_AXI_CLK, "msm_iommu.0", 0),
+	CLK_8X60("iommu_clk",           VFE_AXI_CLK, "msm_iommu.6", 0),
+	CLK_8X60("iommu_clk",           VCODEC_AXI_CLK, "msm_iommu.7", 0),
+	CLK_8X60("iommu_clk",           VCODEC_AXI_CLK, "msm_iommu.8", 0),
+	CLK_8X60("iommu_clk",           GFX3D_CLK, "msm_iommu.9", 0),
+	CLK_8X60("iommu_clk",           GFX2D0_CLK, "msm_iommu.10", 0),
+	CLK_8X60("iommu_clk",           GFX2D1_CLK, "msm_iommu.11", 0),
 };
 
 unsigned msm_num_clocks_8x60 = ARRAY_SIZE(msm_clocks_8x60);
arch/arm/mach-msm/devices-qsd8x50.c +3 -2
index 3b11d28..33a9d13 100644
@@ -17,6 +17,7 @@
 #include <linux/platform_device.h>
 
 #include <linux/dma-mapping.h>
+#include <asm/clkdev.h>
 #include <mach/irqs.h>
 #include <mach/msm_iomap.h>
 #include <mach/dma.h>
@@ -55,7 +56,7 @@ struct platform_device msm_device_smd = {
 	.id     = -1,
 };
 
-struct clk msm_clocks_8x50[] = {
+struct clk_lookup msm_clocks_8x50[] = {
 	CLK_PCOM("adm_clk",	ADM_CLK,	NULL, 0),
 	CLK_PCOM("ce_clk",	CE_CLK,		NULL, 0),
 	CLK_PCOM("ebi1_clk",	EBI1_CLK,	NULL, CLK_MIN),
@@ -92,7 +93,7 @@ struct clk msm_clocks_8x50[] = {
 	CLK_PCOM("tv_enc_clk",	TV_ENC_CLK,	NULL, 0),
 	CLK_PCOM("uart_clk",	UART1_CLK,	NULL, OFF),
 	CLK_PCOM("uart_clk",	UART2_CLK,	NULL, 0),
-	CLK_PCOM("uart_clk",	UART3_CLK,	&msm_device_uart3.dev, OFF),
+	CLK_PCOM("uart_clk",	UART3_CLK,	"msm_serial.2", OFF),
 	CLK_PCOM("uartdm_clk",	UART1DM_CLK,	NULL, OFF),
 	CLK_PCOM("uartdm_clk",	UART2DM_CLK,	NULL, 0),
 	CLK_PCOM("usb_hs_clk",	USB_HS_CLK,	NULL, OFF),
arch/arm/mach-msm/devices.h +4 -4
index 81d2b5d8..72405cf 100644
@@ -39,16 +39,16 @@ extern struct platform_device msm_device_mddi0;
 extern struct platform_device msm_device_mddi1;
 extern struct platform_device msm_device_mdp;
 
-extern struct clk msm_clocks_7x01a[];
+extern struct clk_lookup msm_clocks_7x01a[];
 extern unsigned msm_num_clocks_7x01a;
 
-extern struct clk msm_clocks_7x30[];
+extern struct clk_lookup msm_clocks_7x30[];
 extern unsigned msm_num_clocks_7x30;
 
-extern struct clk msm_clocks_8x50[];
+extern struct clk_lookup msm_clocks_8x50[];
 extern unsigned msm_num_clocks_8x50;
 
-extern struct clk msm_clocks_8x60[];
+extern struct clk_lookup msm_clocks_8x60[];
 extern unsigned msm_num_clocks_8x60;
 
 #endif
arch/arm/mach-msm/include/mach/board.h +3 -1
index 6abf4a6..8652037 100644
@@ -20,6 +20,8 @@
 #include <linux/types.h>
 #include <mach/mmc.h>
 
+#include <asm/clkdev.h>
+
 /* platform device data structures */
 
 struct msm_acpu_clock_platform_data
@@ -41,7 +43,7 @@ void __init msm_add_devices(void);
 void __init msm_map_common_io(void);
 void __init msm_init_irq(void);
 void __init msm_init_gpio(void);
-void __init msm_clock_init(struct clk *clock_tbl, unsigned num_clocks);
+void __init msm_clock_init(struct clk_lookup *clock_tbl, unsigned num_clocks);
 void __init msm_acpu_clock_init(struct msm_acpu_clock_platform_data *);
 int __init msm_add_sdcc(unsigned int controller,
 			struct msm_mmc_platform_data *plat,
arch/arm/mach-msm/include/mach/clkdev.h new file +23 -0
new file mode 100644
index 0000000..939b329
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2010, Code Aurora Forum. 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 Foundation.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+#ifndef __ASM_ARCH_MSM_CLKDEV_H
+#define __ASM_ARCH_MSM_CLKDEV_H
+
+static inline int __clk_get(struct clk *clk) { return 1; }
+static inline void __clk_put(struct clk *clk) { }
+#endif
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#19 lore raw

PATCH 19/22 msm: iommu: Add bus clocks to platform data

In reply to Stephen Boyd

From: Stepan Moskovchenko <[email protected]>

Add the IOMMU bus clock and the IOMMU bus interconnect clocks to the platform data for an IOMMU device. These clocks are needed to access the IOMMU registers.

---
 arch/arm/mach-msm/include/mach/iommu.h |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
arch/arm/mach-msm/include/mach/iommu.h +6 -1
index 296c0f1..62f6699 100644
@@ -19,6 +19,7 @@
 #define MSM_IOMMU_H
 
 #include <linux/interrupt.h>
+#include <linux/clk.h>
 
 /* Sharability attributes of MSM IOMMU mappings */
 #define MSM_IOMMU_ATTR_NON_SH		0x0
@@ -74,13 +75,17 @@ struct msm_iommu_ctx_dev {
  * struct msm_iommu_drvdata - A single IOMMU hardware instance
  * @base:	IOMMU config port base address (VA)
  * @irq:	Interrupt number
-  *
+ * @clk:	The bus clock for this IOMMU hardware instance
+ * @pclk:	The clock for the IOMMU bus interconnect
+ *
  * A msm_iommu_drvdata holds the global driver data about a single piece
  * of an IOMMU hardware instance.
  */
 struct msm_iommu_drvdata {
 	void __iomem *base;
 	int irq;
+	struct clk *clk;
+	struct clk *pclk;
 };
 
 /**
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#20 lore raw

PATCH 20/22 msm: iommu: Clock control for the IOMMU driver

In reply to Stephen Boyd

From: Stepan Moskovchenko <[email protected]>

Add clock control to the IOMMU driver. The IOMMU bus clock (and potentially an AXI clock) need to be on to gain access to IOMMU registers. Actively control these clocks when needed instead of leaving them on.

---
 arch/arm/mach-msm/iommu.c |   57 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 55 insertions(+), 2 deletions(-)
arch/arm/mach-msm/iommu.c +55 -2
index e2d58e4..c6d52ee 100644
@@ -26,6 +26,7 @@
 #include <linux/spinlock.h>
 #include <linux/slab.h>
 #include <linux/iommu.h>
+#include <linux/clk.h>
 
 #include <asm/cacheflush.h>
 #include <asm/sizes.h>
@@ -50,6 +51,30 @@ struct msm_priv {
 	struct list_head list_attached;
 };
 
+static int __enable_clocks(struct msm_iommu_drvdata *drvdata)
+{
+	int ret;
+
+	ret = clk_enable(drvdata->pclk);
+	if (ret)
+		goto fail;
+
+	if (drvdata->clk) {
+		ret = clk_enable(drvdata->clk);
+		if (ret)
+			clk_disable(drvdata->pclk);
+	}
+fail:
+	return ret;
+}
+
+static void __disable_clocks(struct msm_iommu_drvdata *drvdata)
+{
+	if (drvdata->clk)
+		clk_disable(drvdata->clk);
+	clk_disable(drvdata->pclk);
+}
+
 static int __flush_iotlb(struct iommu_domain *domain)
 {
 	struct msm_priv *priv = domain->priv;
@@ -77,9 +102,17 @@ static int __flush_iotlb(struct iommu_domain *domain)
 			BUG();
 
 		iommu_drvdata = dev_get_drvdata(ctx_drvdata->pdev->dev.parent);
+		if (!iommu_drvdata)
+			BUG();
+
+		ret = __enable_clocks(iommu_drvdata);
+		if (ret)
+			goto fail;
+
 		SET_CTX_TLBIALL(iommu_drvdata->base, ctx_drvdata->num, 0);
+		__disable_clocks(iommu_drvdata);
 	}
-
+fail:
 	return ret;
 }
 
@@ -265,9 +298,14 @@ static int msm_iommu_attach_dev(struct iommu_domain *domain, struct device *dev)
 			goto fail;
 		}
 
+	ret = __enable_clocks(iommu_drvdata);
+	if (ret)
+		goto fail;
+
 	__program_context(iommu_drvdata->base, ctx_dev->num,
 			  __pa(priv->pgtable));
 
+	__disable_clocks(iommu_drvdata);
 	list_add(&(ctx_drvdata->attached_elm), &priv->list_attached);
 	ret = __flush_iotlb(domain);
 
@@ -303,7 +341,12 @@ static void msm_iommu_detach_dev(struct iommu_domain *domain,
 	if (ret)
 		goto fail;
 
+	ret = __enable_clocks(iommu_drvdata);
+	if (ret)
+		goto fail;
+
 	__reset_context(iommu_drvdata->base, ctx_dev->num);
+	__disable_clocks(iommu_drvdata);
 	list_del_init(&ctx_drvdata->attached_elm);
 
 fail:
@@ -532,6 +575,10 @@ static phys_addr_t msm_iommu_iova_to_phys(struct iommu_domain *domain,
 	base = iommu_drvdata->base;
 	ctx = ctx_drvdata->num;
 
+	ret = __enable_clocks(iommu_drvdata);
+	if (ret)
+		goto fail;
+
 	/* Invalidate context TLB */
 	SET_CTX_TLBIALL(base, ctx, 0);
 	SET_V2PPR_VA(base, ctx, va >> V2Pxx_VA_SHIFT);
@@ -547,6 +594,7 @@ static phys_addr_t msm_iommu_iova_to_phys(struct iommu_domain *domain,
 	if (GET_FAULT(base, ctx))
 		ret = 0;
 
+	__disable_clocks(iommu_drvdata);
 fail:
 	spin_unlock_irqrestore(&msm_iommu_lock, flags);
 	return ret;
@@ -590,7 +638,7 @@ irqreturn_t msm_iommu_fault_handler(int irq, void *dev_id)
 	struct msm_iommu_drvdata *drvdata = dev_id;
 	void __iomem *base;
 	unsigned int fsr;
-	int ncb, i;
+	int ncb, i, ret;
 
 	spin_lock(&msm_iommu_lock);
 
@@ -604,6 +652,10 @@ irqreturn_t msm_iommu_fault_handler(int irq, void *dev_id)
 	pr_err("Unexpected IOMMU page fault!\n");
 	pr_err("base = %08x\n", (unsigned int) base);
 
+	ret = __enable_clocks(drvdata);
+	if (ret)
+		goto fail;
+
 	ncb = GET_NCB(base)+1;
 	for (i = 0; i < ncb; i++) {
 		fsr = GET_FSR(base, i);
@@ -614,6 +666,7 @@ irqreturn_t msm_iommu_fault_handler(int irq, void *dev_id)
 			SET_FSR(base, i, 0x4000000F);
 		}
 	}
+	__disable_clocks(drvdata);
 fail:
 	spin_unlock(&msm_iommu_lock);
 	return 0;
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#21 lore raw

PATCH 21/22 msm: iommu: Rework clock logic and add IOMMU bus clock control

In reply to Stephen Boyd

From: Stepan Moskovchenko <[email protected]>

Clean up the clock control code in the probe calls, and add support for controlling the clock for the IOMMU bus interconnect. With the (proper) clock driver in place, the clock control logic in the probe function can be made much cleaner since it does not have to deal with the placeholder driver anymore.

---
 arch/arm/mach-msm/devices-msm8x60-iommu.c |    5 -
 arch/arm/mach-msm/include/mach/iommu.h    |    5 -
 arch/arm/mach-msm/iommu_dev.c             |  204 +++++++++++++++++------------
 3 files changed, 120 insertions(+), 94 deletions(-)
arch/arm/mach-msm/devices-msm8x60-iommu.c +0 -5
index f9e7bd3..e12d7e2 100644
@@ -282,7 +282,6 @@ static struct platform_device msm_root_iommu_dev = {
 
 static struct msm_iommu_dev jpegd_iommu = {
 	.name = "jpegd",
-	.clk_rate = -1
 };
 
 static struct msm_iommu_dev vpe_iommu = {
@@ -307,7 +306,6 @@ static struct msm_iommu_dev ijpeg_iommu = {
 
 static struct msm_iommu_dev vfe_iommu = {
 	.name = "vfe",
-	.clk_rate = -1
 };
 
 static struct msm_iommu_dev vcodec_a_iommu = {
@@ -320,17 +318,14 @@ static struct msm_iommu_dev vcodec_b_iommu = {
 
 static struct msm_iommu_dev gfx3d_iommu = {
 	.name = "gfx3d",
-	.clk_rate = 27000000
 };
 
 static struct msm_iommu_dev gfx2d0_iommu = {
 	.name = "gfx2d0",
-	.clk_rate = 27000000
 };
 
 static struct msm_iommu_dev gfx2d1_iommu = {
 	.name = "gfx2d1",
-	.clk_rate = 27000000
 };
 
 static struct platform_device msm_device_iommu_jpegd = {
arch/arm/mach-msm/include/mach/iommu.h +0 -5
index 62f6699..10811ba 100644
@@ -45,14 +45,9 @@
 /**
  * struct msm_iommu_dev - a single IOMMU hardware instance
  * name		Human-readable name given to this IOMMU HW instance
- * clk_rate	Rate to set for this IOMMU's clock, if applicable to this
- *		particular IOMMU. 0 means don't set a rate.
- *		-1 means it is an AXI clock with no valid rate
- *
  */
 struct msm_iommu_dev {
 	const char *name;
-	int clk_rate;
 };
 
 /**
arch/arm/mach-msm/iommu_dev.c +120 -84

271 lines not on this page · raw message

Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#22 lore raw

PATCH 22/22 msm: clock-8x60: Don't keep IOMMU clocks on at boot

In reply to Stephen Boyd

Now that the IOMMU driver properly handles its clocks we can stop keeping the clocks it requires to be on during early boot.

---
 arch/arm/mach-msm/clock-8x60.c |    9 ---------
 1 files changed, 0 insertions(+), 9 deletions(-)
arch/arm/mach-msm/clock-8x60.c +0 -9
index 28017b7..78f33ef 100644
@@ -1851,15 +1851,6 @@ static void reg_init(void)
 	/* Set the dsi_byte_clk src to the DSI PHY PLL,
 	 * dsi_esc_clk to PXO/2, and the hdmi_app_clk src to PXO */
 	rmwreg(0x400001, MISC_CC2_REG, 0x424003);
-
-	/*
-	 * Turn on clocks required by the SMMU driver until it properly
-	 * controls its own clocks.
-	 */
-	local_clk_enable(C(SMMU_P));
-	local_clk_enable(C(JPEGD_AXI));
-	local_clk_enable(C(VFE_AXI));
-	local_clk_enable(C(VCODEC_AXI));
 }
 
 /* Local clock driver initialization. */
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.