All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: mach-shmobile: clock-sh73a0: modify MSTP order
@ 2010-11-24  7:41 Kuninori Morimoto
  2010-11-25  7:28 ` Paul Mundt
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Kuninori Morimoto @ 2010-11-24  7:41 UTC (permalink / raw)
  To: linux-sh

This patch permuted clock arrays in the order of MSTP

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 arch/arm/mach-shmobile/clock-sh73a0.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-shmobile/clock-sh73a0.c b/arch/arm/mach-shmobile/clock-sh73a0.c
index 6e48aae..81fd429 100644
--- a/arch/arm/mach-shmobile/clock-sh73a0.c
+++ b/arch/arm/mach-shmobile/clock-sh73a0.c
@@ -51,10 +51,11 @@ static struct clk *main_clks[] = {
 	&hp_clk,
 };
 
-enum { MSTP219,
-	MSTP001, MSTP116, MSTP207, MSTP206, MSTP204, MSTP203, MSTP202,
-	MSTP201, MSTP200, MSTP323, MSTP331, MSTP329, MSTP312, MSTP411,
-	MSTP410, MSTP403,
+enum {	MSTP001,
+	MSTP116,
+	MSTP219, MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200,
+	MSTP331, MSTP329, MSTP323,
+	MSTP411, MSTP410, MSTP403,
 	MSTP_NR };
 
 #define MSTP(_parent, _reg, _bit, _flags) \
@@ -62,8 +63,8 @@ enum { MSTP219,
 
 static struct clk mstp_clks[MSTP_NR] = {
 	[MSTP001] = MSTP(&hp_clk, SMSTPCR0, 1, 0), /* I2C2 */
-	[MSTP219] = MSTP(&sub_clk, SMSTPCR2, 19, 0), /* SCIFA7 */
 	[MSTP116] = MSTP(&hp_clk, SMSTPCR1, 16, 0), /* I2C0 */
+	[MSTP219] = MSTP(&sub_clk, SMSTPCR2, 19, 0), /* SCIFA7 */
 	[MSTP207] = MSTP(&sub_clk, SMSTPCR2, 7, 0), /* SCIFA5 */
 	[MSTP206] = MSTP(&sub_clk, SMSTPCR2, 6, 0), /* SCIFB */
 	[MSTP204] = MSTP(&sub_clk, SMSTPCR2, 4, 0), /* SCIFA0 */
@@ -74,15 +75,17 @@ static struct clk mstp_clks[MSTP_NR] = {
 	[MSTP331] = MSTP(&sub_clk, SMSTPCR3, 31, 0), /* SCIFA6 */
 	[MSTP329] = MSTP(&r_clk, SMSTPCR3, 29, 0), /* CMT10 */
 	[MSTP323] = MSTP(&hp_clk, SMSTPCR3, 23, 0), /* I2C1 */
-	[MSTP403] = MSTP(&r_clk, SMSTPCR4, 0, 0), /* KEYSC0 */
 	[MSTP411] = MSTP(&hp_clk, SMSTPCR4, 11, 0), /* I2C3 */
 	[MSTP410] = MSTP(&hp_clk, SMSTPCR4, 10, 0), /* I2C4 */
+	[MSTP403] = MSTP(&r_clk, SMSTPCR4, 0, 0), /* KEYSC0 */
 };
 
 #define CLKDEV_DEV_ID(_id, _clk) { .dev_id = _id, .clk = _clk }
 
 static struct clk_lookup lookups[] = {
 	/* MSTP32 clocks */
+	CLKDEV_DEV_ID("i2c-sh_mobile.2", &mstp_clks[MSTP001]), /* I2C2 */
+	CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[MSTP116]), /* I2C0 */
 	CLKDEV_DEV_ID("sh-sci.7", &mstp_clks[MSTP219]), /* SCIFA7 */
 	CLKDEV_DEV_ID("sh-sci.5", &mstp_clks[MSTP207]), /* SCIFA5 */
 	CLKDEV_DEV_ID("sh-sci.8", &mstp_clks[MSTP206]), /* SCIFB */
@@ -93,12 +96,10 @@ static struct clk_lookup lookups[] = {
 	CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[MSTP200]), /* SCIFA4 */
 	CLKDEV_DEV_ID("sh-sci.6", &mstp_clks[MSTP331]), /* SCIFA6 */
 	CLKDEV_DEV_ID("sh_cmt.10", &mstp_clks[MSTP329]), /* CMT10 */
-	CLKDEV_DEV_ID("sh_keysc.0", &mstp_clks[MSTP403]), /* KEYSC0 */
-	CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[MSTP116]), /* I2C0 */
 	CLKDEV_DEV_ID("i2c-sh_mobile.1", &mstp_clks[MSTP323]), /* I2C1 */
-	CLKDEV_DEV_ID("i2c-sh_mobile.2", &mstp_clks[MSTP001]), /* I2C2 */
 	CLKDEV_DEV_ID("i2c-sh_mobile.3", &mstp_clks[MSTP411]), /* I2C3 */
 	CLKDEV_DEV_ID("i2c-sh_mobile.4", &mstp_clks[MSTP410]), /* I2C4 */
+	CLKDEV_DEV_ID("sh_keysc.0", &mstp_clks[MSTP403]), /* KEYSC0 */
 };
 
 void __init sh73a0_clock_init(void)
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] ARM: mach-shmobile: clock-sh73a0: modify MSTP order
  2010-11-24  7:41 [PATCH] ARM: mach-shmobile: clock-sh73a0: modify MSTP order Kuninori Morimoto
@ 2010-11-25  7:28 ` Paul Mundt
  2011-08-26  7:27 ` [PATCH] ARM: mach-shmobile: clock-sh73a0: tidyup CKSCR main clock selecter Kuninori Morimoto
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Paul Mundt @ 2010-11-25  7:28 UTC (permalink / raw)
  To: linux-sh

On Wed, Nov 24, 2010 at 04:41:14PM +0900, Kuninori Morimoto wrote:
> This patch permuted clock arrays in the order of MSTP
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] ARM: mach-shmobile: clock-sh73a0: tidyup CKSCR main clock selecter
  2010-11-24  7:41 [PATCH] ARM: mach-shmobile: clock-sh73a0: modify MSTP order Kuninori Morimoto
  2010-11-25  7:28 ` Paul Mundt
@ 2011-08-26  7:27 ` Kuninori Morimoto
  2011-08-29  3:36 ` Magnus Damm
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Kuninori Morimoto @ 2011-08-26  7:27 UTC (permalink / raw)
  To: linux-sh

MAINCKSEL is [29:28], not [27:24]

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 arch/arm/mach-shmobile/clock-sh73a0.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-shmobile/clock-sh73a0.c b/arch/arm/mach-shmobile/clock-sh73a0.c
index 7da8af6..84fd33c 100644
--- a/arch/arm/mach-shmobile/clock-sh73a0.c
+++ b/arch/arm/mach-shmobile/clock-sh73a0.c
@@ -365,7 +365,7 @@ void __init sh73a0_clock_init(void)
 	__raw_writel(0x108, SD2CKCR);
 
 	/* detect main clock parent */
-	switch ((__raw_readl(CKSCR) >> 24) & 0x03) {
+	switch ((__raw_readl(CKSCR) >> 28) & 0x03) {
 	case 0:
 		main_clk.parent = &sh73a0_extal1_clk;
 		break;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] ARM: mach-shmobile: clock-sh73a0: tidyup CKSCR main clock selecter
  2010-11-24  7:41 [PATCH] ARM: mach-shmobile: clock-sh73a0: modify MSTP order Kuninori Morimoto
  2010-11-25  7:28 ` Paul Mundt
  2011-08-26  7:27 ` [PATCH] ARM: mach-shmobile: clock-sh73a0: tidyup CKSCR main clock selecter Kuninori Morimoto
@ 2011-08-29  3:36 ` Magnus Damm
  2011-08-29  4:13 ` Kuninori Morimoto
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Magnus Damm @ 2011-08-29  3:36 UTC (permalink / raw)
  To: linux-sh

On Fri, Aug 26, 2011 at 4:27 PM, Kuninori Morimoto
<kuninori.morimoto.gx@renesas.com> wrote:
> MAINCKSEL is [29:28], not [27:24]
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

This matches the data sheet, thanks for submitting this Morimoto-san.

In the future, please include the word "bug fix" in the subject so we
can tell it's a bug fix.

Thanks,

/ magnus

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ARM: mach-shmobile: clock-sh73a0: tidyup CKSCR main clock selecter
  2010-11-24  7:41 [PATCH] ARM: mach-shmobile: clock-sh73a0: modify MSTP order Kuninori Morimoto
                   ` (2 preceding siblings ...)
  2011-08-29  3:36 ` Magnus Damm
@ 2011-08-29  4:13 ` Kuninori Morimoto
  2011-08-29  7:27 ` Paul Mundt
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Kuninori Morimoto @ 2011-08-29  4:13 UTC (permalink / raw)
  To: linux-sh


Hi Magnus

Thank you for checking my patch

> > MAINCKSEL is [29:28], not [27:24]
> >
> > Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> This matches the data sheet, thanks for submitting this Morimoto-san.
> 
> In the future, please include the word "bug fix" in the subject so we
> can tell it's a bug fix.

Thank you for pointing it.
I will do

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ARM: mach-shmobile: clock-sh73a0: tidyup CKSCR main clock selecter
  2010-11-24  7:41 [PATCH] ARM: mach-shmobile: clock-sh73a0: modify MSTP order Kuninori Morimoto
                   ` (3 preceding siblings ...)
  2011-08-29  4:13 ` Kuninori Morimoto
@ 2011-08-29  7:27 ` Paul Mundt
  2012-01-23  5:10 ` [PATCH] ARM: mach-shmobile: clock-sh73a0: add DSIxPHY clock support Kuninori Morimoto
  2012-01-24  1:41 ` Paul Mundt
  6 siblings, 0 replies; 8+ messages in thread
From: Paul Mundt @ 2011-08-29  7:27 UTC (permalink / raw)
  To: linux-sh

On Fri, Aug 26, 2011 at 12:27:45AM -0700, Kuninori Morimoto wrote:
> MAINCKSEL is [29:28], not [27:24]
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  arch/arm/mach-shmobile/clock-sh73a0.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
Applied, thanks.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] ARM: mach-shmobile: clock-sh73a0: add DSIxPHY clock support
  2010-11-24  7:41 [PATCH] ARM: mach-shmobile: clock-sh73a0: modify MSTP order Kuninori Morimoto
                   ` (4 preceding siblings ...)
  2011-08-29  7:27 ` Paul Mundt
@ 2012-01-23  5:10 ` Kuninori Morimoto
  2012-01-24  1:41 ` Paul Mundt
  6 siblings, 0 replies; 8+ messages in thread
From: Kuninori Morimoto @ 2012-01-23  5:10 UTC (permalink / raw)
  To: linux-sh

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 arch/arm/mach-shmobile/board-ag5evm.c |   16 ++++-
 arch/arm/mach-shmobile/clock-sh73a0.c |  113 +++++++++++++++++++++++++++++++++
 2 files changed, 125 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c
index eff8a96..9952f0a 100644
--- a/arch/arm/mach-shmobile/board-ag5evm.c
+++ b/arch/arm/mach-shmobile/board-ag5evm.c
@@ -321,12 +321,11 @@ static struct resource mipidsi0_resources[] = {
 	},
 };
 
-#define DSI0PHYCR	0xe615006c
 static int sh_mipi_set_dot_clock(struct platform_device *pdev,
 				 void __iomem *base,
 				 int enable)
 {
-	struct clk *pck;
+	struct clk *pck, *phy;
 	int ret;
 
 	pck = clk_get(&pdev->dev, "dsip_clk");
@@ -335,18 +334,27 @@ static int sh_mipi_set_dot_clock(struct platform_device *pdev,
 		goto sh_mipi_set_dot_clock_pck_err;
 	}
 
+	phy = clk_get(&pdev->dev, "dsiphy_clk");
+	if (IS_ERR(phy)) {
+		ret = PTR_ERR(phy);
+		goto sh_mipi_set_dot_clock_phy_err;
+	}
+
 	if (enable) {
 		clk_set_rate(pck, clk_round_rate(pck,  24000000));
-		__raw_writel(0x2a809010, DSI0PHYCR);
+		clk_set_rate(phy, clk_round_rate(pck, 510000000));
 		clk_enable(pck);
+		clk_enable(phy);
 	} else {
 		clk_disable(pck);
+		clk_disable(phy);
 	}
 
 	ret = 0;
 
+	clk_put(phy);
+sh_mipi_set_dot_clock_phy_err:
 	clk_put(pck);
-
 sh_mipi_set_dot_clock_pck_err:
 	return ret;
 }
diff --git a/arch/arm/mach-shmobile/clock-sh73a0.c b/arch/arm/mach-shmobile/clock-sh73a0.c
index afbead6..7727cca 100644
--- a/arch/arm/mach-shmobile/clock-sh73a0.c
+++ b/arch/arm/mach-shmobile/clock-sh73a0.c
@@ -365,6 +365,114 @@ static struct clk div6_clks[DIV6_NR] = {
 			dsi_parent, ARRAY_SIZE(dsi_parent), 12, 3),
 };
 
+/* DSI DIV */
+static unsigned long dsiphy_recalc(struct clk *clk)
+{
+	u32 value;
+
+	value = __raw_readl(clk->mapping->base);
+
+	/* FIXME */
+	if (!(value & 0x000B8000))
+		return clk->parent->rate;
+
+	value &= 0x3f;
+	value += 1;
+
+	if ((value < 12) ||
+	    (value > 33)) {
+		pr_err("DSIPHY has wrong value (%d)", value);
+		return 0;
+	}
+
+	return clk->parent->rate / value;
+}
+
+static long dsiphy_round_rate(struct clk *clk, unsigned long rate)
+{
+	return clk_rate_mult_range_round(clk, 12, 33, rate);
+}
+
+static void dsiphy_disable(struct clk *clk)
+{
+	u32 value;
+
+	value = __raw_readl(clk->mapping->base);
+	value &= ~0x000B8000;
+
+	__raw_writel(value , clk->mapping->base);
+}
+
+static int dsiphy_enable(struct clk *clk)
+{
+	u32 value;
+	int multi;
+
+	value = __raw_readl(clk->mapping->base);
+	multi = (value & 0x3f) + 1;
+
+	if ((multi < 12) || (multi > 33))
+		return -EIO;
+
+	__raw_writel(value | 0x000B8000, clk->mapping->base);
+
+	return 0;
+}
+
+static int dsiphy_set_rate(struct clk *clk, unsigned long rate)
+{
+	u32 value;
+	int idx;
+
+	idx = rate / clk->parent->rate;
+	if ((idx < 12) || (idx > 33))
+		return -EINVAL;
+
+	idx += -1;
+
+	value = __raw_readl(clk->mapping->base);
+	value = (value & ~0x3f) + idx;
+
+	__raw_writel(value, clk->mapping->base);
+
+	return 0;
+}
+
+static struct clk_ops dsiphy_clk_ops = {
+	.recalc		= dsiphy_recalc,
+	.round_rate	= dsiphy_round_rate,
+	.set_rate	= dsiphy_set_rate,
+	.enable		= dsiphy_enable,
+	.disable	= dsiphy_disable,
+};
+
+static struct clk_mapping dsi0phy_clk_mapping = {
+	.phys	= DSI0PHYCR,
+	.len	= 4,
+};
+
+static struct clk_mapping dsi1phy_clk_mapping = {
+	.phys	= DSI1PHYCR,
+	.len	= 4,
+};
+
+static struct clk dsi0phy_clk = {
+	.ops		= &dsiphy_clk_ops,
+	.parent		= &div6_clks[DIV6_DSI0P], /* late install */
+	.mapping	= &dsi0phy_clk_mapping,
+};
+
+static struct clk dsi1phy_clk = {
+	.ops		= &dsiphy_clk_ops,
+	.parent		= &div6_clks[DIV6_DSI1P], /* late install */
+	.mapping	= &dsi1phy_clk_mapping,
+};
+
+static struct clk *late_main_clks[] = {
+	&dsi0phy_clk,
+	&dsi1phy_clk,
+};
+
 enum { MSTP001,
 	MSTP129, MSTP128, MSTP127, MSTP126, MSTP125, MSTP118, MSTP116, MSTP100,
 	MSTP219,
@@ -429,6 +537,8 @@ static struct clk_lookup lookups[] = {
 	CLKDEV_ICK_ID("dsit_clk", "sh-mipi-dsi.1", &div6_clks[DIV6_DSIT]),
 	CLKDEV_ICK_ID("dsip_clk", "sh-mipi-dsi.0", &div6_clks[DIV6_DSI0P]),
 	CLKDEV_ICK_ID("dsip_clk", "sh-mipi-dsi.1", &div6_clks[DIV6_DSI1P]),
+	CLKDEV_ICK_ID("dsiphy_clk", "sh-mipi-dsi.0", &dsi0phy_clk),
+	CLKDEV_ICK_ID("dsiphy_clk", "sh-mipi-dsi.1", &dsi1phy_clk),
 
 	/* MSTP32 clocks */
 	CLKDEV_DEV_ID("i2c-sh_mobile.2", &mstp_clks[MSTP001]), /* I2C2 */
@@ -504,6 +614,9 @@ void __init sh73a0_clock_init(void)
 	if (!ret)
 		ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR);
 
+	for (k = 0; !ret && (k < ARRAY_SIZE(late_main_clks)); k++)
+		ret = clk_register(late_main_clks[k]);
+
 	clkdev_add_table(lookups, ARRAY_SIZE(lookups));
 
 	if (!ret)
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] ARM: mach-shmobile: clock-sh73a0: add DSIxPHY clock support
  2010-11-24  7:41 [PATCH] ARM: mach-shmobile: clock-sh73a0: modify MSTP order Kuninori Morimoto
                   ` (5 preceding siblings ...)
  2012-01-23  5:10 ` [PATCH] ARM: mach-shmobile: clock-sh73a0: add DSIxPHY clock support Kuninori Morimoto
@ 2012-01-24  1:41 ` Paul Mundt
  6 siblings, 0 replies; 8+ messages in thread
From: Paul Mundt @ 2012-01-24  1:41 UTC (permalink / raw)
  To: linux-sh

On Sun, Jan 22, 2012 at 09:10:02PM -0800, Kuninori Morimoto wrote:
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  arch/arm/mach-shmobile/board-ag5evm.c |   16 ++++-
>  arch/arm/mach-shmobile/clock-sh73a0.c |  113 +++++++++++++++++++++++++++++++++
>  2 files changed, 125 insertions(+), 4 deletions(-)

Applied, thanks.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-01-24  1:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-24  7:41 [PATCH] ARM: mach-shmobile: clock-sh73a0: modify MSTP order Kuninori Morimoto
2010-11-25  7:28 ` Paul Mundt
2011-08-26  7:27 ` [PATCH] ARM: mach-shmobile: clock-sh73a0: tidyup CKSCR main clock selecter Kuninori Morimoto
2011-08-29  3:36 ` Magnus Damm
2011-08-29  4:13 ` Kuninori Morimoto
2011-08-29  7:27 ` Paul Mundt
2012-01-23  5:10 ` [PATCH] ARM: mach-shmobile: clock-sh73a0: add DSIxPHY clock support Kuninori Morimoto
2012-01-24  1:41 ` Paul Mundt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.