All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: S5P64X0: Add the devname for DMA clock
@ 2011-08-18  6:43 ` Boojin Kim
  0 siblings, 0 replies; 12+ messages in thread
From: Boojin Kim @ 2011-08-18  6:43 UTC (permalink / raw)
  To: linux-arm-kernel, linux-samsung-soc; +Cc: Kukjin Kim, Boojin Kim

This patch adds devname for DMA clock.
NOTE: This patch should be added after merging new pl330 driver on dmaengine.

Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
---
 arch/arm/mach-s5p64x0/clock-s5p6440.c |    1 +
 arch/arm/mach-s5p64x0/clock-s5p6450.c |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-s5p64x0/clock-s5p6440.c b/arch/arm/mach-s5p64x0/clock-s5p6440.c
index c1f548f..c54c65d 100644
--- a/arch/arm/mach-s5p64x0/clock-s5p6440.c
+++ b/arch/arm/mach-s5p64x0/clock-s5p6440.c
@@ -147,6 +147,7 @@ static struct clk init_clocks_off[] = {
 		.ctrlbit	= (1 << 8),
 	}, {
 		.name		= "dma",
+		.devname	= "dma-pl330",
 		.parent		= &clk_hclk_low.clk,
 		.enable		= s5p64x0_hclk0_ctrl,
 		.ctrlbit	= (1 << 12),
diff --git a/arch/arm/mach-s5p64x0/clock-s5p6450.c b/arch/arm/mach-s5p64x0/clock-s5p6450.c
index 3d9b609..2d04abf 100644
--- a/arch/arm/mach-s5p64x0/clock-s5p6450.c
+++ b/arch/arm/mach-s5p64x0/clock-s5p6450.c
@@ -180,6 +180,7 @@ static struct clk init_clocks_off[] = {
 		.ctrlbit	= (1 << 3),
 	}, {
 		.name		= "dma",
+		.devname	= "dma-pl330",
 		.parent		= &clk_hclk_low.clk,
 		.enable		= s5p64x0_hclk0_ctrl,
 		.ctrlbit	= (1 << 12),
-- 
1.7.1

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

* [PATCH] ARM: S5P64X0: Add the devname for DMA clock
@ 2011-08-18  6:43 ` Boojin Kim
  0 siblings, 0 replies; 12+ messages in thread
From: Boojin Kim @ 2011-08-18  6:43 UTC (permalink / raw)
  To: linux-arm-kernel

This patch adds devname for DMA clock.
NOTE: This patch should be added after merging new pl330 driver on dmaengine.

Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
---
 arch/arm/mach-s5p64x0/clock-s5p6440.c |    1 +
 arch/arm/mach-s5p64x0/clock-s5p6450.c |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-s5p64x0/clock-s5p6440.c b/arch/arm/mach-s5p64x0/clock-s5p6440.c
index c1f548f..c54c65d 100644
--- a/arch/arm/mach-s5p64x0/clock-s5p6440.c
+++ b/arch/arm/mach-s5p64x0/clock-s5p6440.c
@@ -147,6 +147,7 @@ static struct clk init_clocks_off[] = {
 		.ctrlbit	= (1 << 8),
 	}, {
 		.name		= "dma",
+		.devname	= "dma-pl330",
 		.parent		= &clk_hclk_low.clk,
 		.enable		= s5p64x0_hclk0_ctrl,
 		.ctrlbit	= (1 << 12),
diff --git a/arch/arm/mach-s5p64x0/clock-s5p6450.c b/arch/arm/mach-s5p64x0/clock-s5p6450.c
index 3d9b609..2d04abf 100644
--- a/arch/arm/mach-s5p64x0/clock-s5p6450.c
+++ b/arch/arm/mach-s5p64x0/clock-s5p6450.c
@@ -180,6 +180,7 @@ static struct clk init_clocks_off[] = {
 		.ctrlbit	= (1 << 3),
 	}, {
 		.name		= "dma",
+		.devname	= "dma-pl330",
 		.parent		= &clk_hclk_low.clk,
 		.enable		= s5p64x0_hclk0_ctrl,
 		.ctrlbit	= (1 << 12),
-- 
1.7.1

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

* RE: [PATCH] ARM: S5P64X0: Add the devname for DMA clock
  2011-08-18  6:43 ` Boojin Kim
@ 2011-08-19  5:24   ` Kukjin Kim
  -1 siblings, 0 replies; 12+ messages in thread
From: Kukjin Kim @ 2011-08-19  5:24 UTC (permalink / raw)
  To: 'Boojin Kim', linux-arm-kernel, linux-samsung-soc

Boojin Kim wrote:
> 
> This patch adds devname for DMA clock.
> NOTE: This patch should be added after merging new pl330 driver on
dmaengine.
> 
> Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
> ---
>  arch/arm/mach-s5p64x0/clock-s5p6440.c |    1 +
>  arch/arm/mach-s5p64x0/clock-s5p6450.c |    1 +
>  2 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-s5p64x0/clock-s5p6440.c b/arch/arm/mach-
> s5p64x0/clock-s5p6440.c
> index c1f548f..c54c65d 100644
> --- a/arch/arm/mach-s5p64x0/clock-s5p6440.c
> +++ b/arch/arm/mach-s5p64x0/clock-s5p6440.c
> @@ -147,6 +147,7 @@ static struct clk init_clocks_off[] = {
>  		.ctrlbit	= (1 << 8),
>  	}, {
>  		.name		= "dma",
> +		.devname	= "dma-pl330",
>  		.parent		= &clk_hclk_low.clk,
>  		.enable		= s5p64x0_hclk0_ctrl,
>  		.ctrlbit	= (1 << 12),
> diff --git a/arch/arm/mach-s5p64x0/clock-s5p6450.c b/arch/arm/mach-
> s5p64x0/clock-s5p6450.c
> index 3d9b609..2d04abf 100644
> --- a/arch/arm/mach-s5p64x0/clock-s5p6450.c
> +++ b/arch/arm/mach-s5p64x0/clock-s5p6450.c
> @@ -180,6 +180,7 @@ static struct clk init_clocks_off[] = {
>  		.ctrlbit	= (1 << 3),
>  	}, {
>  		.name		= "dma",
> +		.devname	= "dma-pl330",
>  		.parent		= &clk_hclk_low.clk,
>  		.enable		= s5p64x0_hclk0_ctrl,
>  		.ctrlbit	= (1 << 12),
> --
> 1.7.1

OK, will apply.
Thanks.

Best regards,
Kgene.
--
Kukjin Kim <kgene.kim@samsung.com>, Senior Engineer,
SW Solution Development Team, Samsung Electronics Co., Ltd.

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

* [PATCH] ARM: S5P64X0: Add the devname for DMA clock
@ 2011-08-19  5:24   ` Kukjin Kim
  0 siblings, 0 replies; 12+ messages in thread
From: Kukjin Kim @ 2011-08-19  5:24 UTC (permalink / raw)
  To: linux-arm-kernel

Boojin Kim wrote:
> 
> This patch adds devname for DMA clock.
> NOTE: This patch should be added after merging new pl330 driver on
dmaengine.
> 
> Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
> ---
>  arch/arm/mach-s5p64x0/clock-s5p6440.c |    1 +
>  arch/arm/mach-s5p64x0/clock-s5p6450.c |    1 +
>  2 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-s5p64x0/clock-s5p6440.c b/arch/arm/mach-
> s5p64x0/clock-s5p6440.c
> index c1f548f..c54c65d 100644
> --- a/arch/arm/mach-s5p64x0/clock-s5p6440.c
> +++ b/arch/arm/mach-s5p64x0/clock-s5p6440.c
> @@ -147,6 +147,7 @@ static struct clk init_clocks_off[] = {
>  		.ctrlbit	= (1 << 8),
>  	}, {
>  		.name		= "dma",
> +		.devname	= "dma-pl330",
>  		.parent		= &clk_hclk_low.clk,
>  		.enable		= s5p64x0_hclk0_ctrl,
>  		.ctrlbit	= (1 << 12),
> diff --git a/arch/arm/mach-s5p64x0/clock-s5p6450.c b/arch/arm/mach-
> s5p64x0/clock-s5p6450.c
> index 3d9b609..2d04abf 100644
> --- a/arch/arm/mach-s5p64x0/clock-s5p6450.c
> +++ b/arch/arm/mach-s5p64x0/clock-s5p6450.c
> @@ -180,6 +180,7 @@ static struct clk init_clocks_off[] = {
>  		.ctrlbit	= (1 << 3),
>  	}, {
>  		.name		= "dma",
> +		.devname	= "dma-pl330",
>  		.parent		= &clk_hclk_low.clk,
>  		.enable		= s5p64x0_hclk0_ctrl,
>  		.ctrlbit	= (1 << 12),
> --
> 1.7.1

OK, will apply.
Thanks.

Best regards,
Kgene.
--
Kukjin Kim <kgene.kim@samsung.com>, Senior Engineer,
SW Solution Development Team, Samsung Electronics Co., Ltd.

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

* [PATCH v4] amba: consolidate PrimeCell magic
       [not found]   ` <001c01cc6082$123cef20$36b6cd60$%kim@samsung.com>
@ 2011-08-22  4:41     ` Boojin Kim
  2011-08-22  7:11       ` Linus Walleij
  0 siblings, 1 reply; 12+ messages in thread
From: Boojin Kim @ 2011-08-22  4:41 UTC (permalink / raw)
  To: linux-arm-kernel

Linus Walleij Wrote:

> From: Linus Walleij <linus.walleij@linaro.org>
>
> Since two drivers use the PrimeCell scheme without using the
> amba_bus driver logic, let's break the magic lookups out as
> static inlines in the <linux/amba/bus.h> header so we get
> some consolidation anyway. Delete the primecell ID check in
> common/pl330.c since it is only used from the amba_bus driver
> in drivers/dma, which is already doing the same check when
> probing in drivers/amba/bus.c.
>
> Cc: Kukjin Kim <kgene.kim@samsung.com>
> Cc: Viresh Kumar <viresh.kumar@st.com>
> Acked-by: H Hartley Sweeten <hartleys@visionengravers.com>
> Acked-by: Jassi Brar <jassisinghbrar@gmail.com>
> Acked-by: Boojin Kim <boojin.kim@samsung.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> Changes V3->v4:
> - Fix up sparse warning due to inelegant cast to (u32) in vic.c,
>   we cast to (unsigned long) and sparse is happy.
> ---
>  arch/arm/common/pl330.c      |   40
> +++-------------------------------------
>  arch/arm/common/vic.c        |   15 ++++++++-------
>  drivers/amba/bus.c           |   19 +++----------------
>  drivers/dma/ste_dma40.c      |   14 ++++----------
>  drivers/mtd/nand/fsmc_nand.c |   10 +++-------
>  include/linux/amba/bus.h     |   26 ++++++++++++++++++++++++++
>  6 files changed, 47 insertions(+), 77 deletions(-)
>
> diff --git a/arch/arm/common/pl330.c b/arch/arm/common/pl330.c
> index 97912fa..623ce74 100644
> --- a/arch/arm/common/pl330.c
> +++ b/arch/arm/common/pl330.c
> @@ -27,6 +27,7 @@
>  #include <linux/delay.h>
>  #include <linux/interrupt.h>
>  #include <linux/dma-mapping.h>
> +#include <linux/amba/bus.h>
>
>  #include <asm/hardware/pl330.h>
>
> @@ -111,9 +112,6 @@
>  #define CR4		0xe10
>  #define CRD		0xe14
>
> -#define PERIPH_ID	0xfe0
> -#define PCELL_ID	0xff0
> -
>  #define CR0_PERIPH_REQ_SET	(1 << 0)
>  #define CR0_BOOT_EN_SET		(1 << 1)
>  #define CR0_BOOT_MAN_NS		(1 << 2)
> @@ -142,14 +140,6 @@
>  #define CRD_DATA_BUFF_SHIFT	20
>  #define CRD_DATA_BUFF_MASK	0x3ff
>
> -#define	PART		0x330
> -#define DESIGNER	0x41
> -#define REVISION	0x0
> -#define INTEG_CFG	0x0
> -#define PERIPH_ID_VAL	((PART << 0) | (DESIGNER << 12))
> -
> -#define PCELL_ID_VAL	0xb105f00d
> -
>  #define PL330_STATE_STOPPED		(1 << 0)
>  #define PL330_STATE_EXECUTING		(1 << 1)
>  #define PL330_STATE_WFE			(1 << 2)
> @@ -372,19 +362,6 @@ static inline bool _manager_ns(struct
> pl330_thread
> *thrd)
>  	return (pl330->pinfo->pcfg.mode & DMAC_MODE_NS) ? true : false;
>  }
>
> -static inline u32 get_id(struct pl330_info *pi, u32 off)
> -{
> -	void __iomem *regs = pi->base;
> -	u32 id = 0;
> -
> -	id |= (readb(regs + off + 0x0) << 0);
> -	id |= (readb(regs + off + 0x4) << 8);
> -	id |= (readb(regs + off + 0x8) << 16);
> -	id |= (readb(regs + off + 0xc) << 24);
> -
> -	return id;
> -}
> -
>  static inline u32 _emit_ADDH(unsigned dry_run, u8 buf[],
>  		enum pl330_dst da, u16 val)
>  {
> @@ -1747,8 +1724,8 @@ static void read_dmac_config(struct pl330_info
> *pi)
>
>  	pi->pcfg.irq_ns = readl(regs + CR3);
>
> -	pi->pcfg.periph_id = get_id(pi, PERIPH_ID);
> -	pi->pcfg.pcell_id = get_id(pi, PCELL_ID);
> +	pi->pcfg.periph_id = amba_get_pid(pi->base, PCELL_SIZE);
> +	pi->pcfg.pcell_id = amba_get_cid(pi->base, PCELL_SIZE);
>  }
I think PCELL_SIZE definition is missed.
V1 had the definition of 'PCELL_SIZE' as following. But, it was gone from
V2.
+/* Used as end offset to retrieve PrimeCell ID registers */
+#define PCELL_SIZE	0x1000

Thanks
Boojin

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

* [PATCH v4] amba: consolidate PrimeCell magic
  2011-08-22  4:41     ` [PATCH v4] amba: consolidate PrimeCell magic Boojin Kim
@ 2011-08-22  7:11       ` Linus Walleij
  2011-08-22 11:57         ` Boojin Kim
  0 siblings, 1 reply; 12+ messages in thread
From: Linus Walleij @ 2011-08-22  7:11 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Aug 22, 2011 at 6:41 AM, Boojin Kim <boojin.kim@samsung.com> wrote:
>> From: Linus Walleij <linus.walleij@linaro.org>

>> Since two drivers use the PrimeCell scheme without using the
>> amba_bus driver logic, let's break the magic lookups out as
>> static inlines in the <linux/amba/bus.h> header so we get
>> some consolidation anyway. Delete the primecell ID check in
>> common/pl330.c since it is only used from the amba_bus driver
>> in drivers/dma, which is already doing the same check when
>> probing in drivers/amba/bus.c.
>
> I think PCELL_SIZE definition is missed.
> V1 had the definition of 'PCELL_SIZE' as following. But, it was gone from
> V2.
> +/* Used as end offset to retrieve PrimeCell ID registers */
> +#define PCELL_SIZE ? ? 0x1000

I must have slipped something :-(

I fixed it by simply switching PCELL_SIZE to SZ_4K in the patch
like this:
-       pi->pcfg.periph_id = get_id(pi, PERIPH_ID);
-       pi->pcfg.pcell_id = get_id(pi, PCELL_ID);
+       pi->pcfg.periph_id = amba_get_pid(pi->base, SZ_4K);
+       pi->pcfg.pcell_id = amba_get_cid(pi->base, SZ_4K);

Which defconfig shall I use to regressiontest this actually?
I was trying to locate one but failed.

I'll update the patch in the patch tracker too.

Yours,
Linus Walleij

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

* [PATCH v4] amba: consolidate PrimeCell magic
  2011-08-22  7:11       ` Linus Walleij
@ 2011-08-22 11:57         ` Boojin Kim
  2011-08-22 12:20           ` Linus Walleij
  0 siblings, 1 reply; 12+ messages in thread
From: Boojin Kim @ 2011-08-22 11:57 UTC (permalink / raw)
  To: linux-arm-kernel

Linus Walleij wrote:
> >> From: Linus Walleij <linus.walleij@linaro.org>
>
> >> Since two drivers use the PrimeCell scheme without using the
> >> amba_bus driver logic, let's break the magic lookups out as
> >> static inlines in the <linux/amba/bus.h> header so we get
> >> some consolidation anyway. Delete the primecell ID check in
> >> common/pl330.c since it is only used from the amba_bus driver
> >> in drivers/dma, which is already doing the same check when
> >> probing in drivers/amba/bus.c.
> >
> > I think PCELL_SIZE definition is missed.
> > V1 had the definition of 'PCELL_SIZE' as following. But, it was gone
> from
> > V2.
> > +/* Used as end offset to retrieve PrimeCell ID registers */
> > +#define PCELL_SIZE ? ? 0x1000
>
> I must have slipped something :-(
>
> I fixed it by simply switching PCELL_SIZE to SZ_4K in the patch
> like this:
> -       pi->pcfg.periph_id = get_id(pi, PERIPH_ID);
> -       pi->pcfg.pcell_id = get_id(pi, PCELL_ID);
> +       pi->pcfg.periph_id = amba_get_pid(pi->base, SZ_4K);
> +       pi->pcfg.pcell_id = amba_get_cid(pi->base, SZ_4K);
>
> Which defconfig shall I use to regressiontest this actually?
> I was trying to locate one but failed.
>
> I'll update the patch in the patch tracker too.
>
> Yours,
> Linus Walleij

I used 'exynos4_defconfig'. And then enables 'Device Drivers-> DMA Engine
support -> DMA API Driver for PL330' option and modify code as below.

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 2e3b3d3..763e846 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -193,6 +193,7 @@ config ARCH_HAS_ASYNC_TX_FIND_CHANNEL
 config PL330_DMA
 	tristate "DMA API Driver for PL330"
 	select DMA_ENGINE
+	select ARM_AMBA
 	depends on PL330
 	help
 	  Select if your platform has one or more PL330 DMACs.
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 00eee59..fcad90c 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -17,6 +17,7 @@
 #include <linux/interrupt.h>
 #include <linux/amba/bus.h>
 #include <linux/amba/pl330.h>
+#include <linux/scatterlist.h>

 #define NR_DEFAULT_DESC	16

Thanks
Boojin

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

* [PATCH v4] amba: consolidate PrimeCell magic
  2011-08-22 11:57         ` Boojin Kim
@ 2011-08-22 12:20           ` Linus Walleij
  0 siblings, 0 replies; 12+ messages in thread
From: Linus Walleij @ 2011-08-22 12:20 UTC (permalink / raw)
  To: linux-arm-kernel

2011/8/22 Boojin Kim <boojin.kim@samsung.com>:

> I used 'exynos4_defconfig'. And then enables 'Device Drivers-> DMA Engine
> support -> DMA API Driver for PL330' option and modify code as below.
>
> diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
> index 2e3b3d3..763e846 100644
> --- a/drivers/dma/Kconfig
> +++ b/drivers/dma/Kconfig
> @@ -193,6 +193,7 @@ config ARCH_HAS_ASYNC_TX_FIND_CHANNEL
> ?config PL330_DMA
> ? ? ? ?tristate "DMA API Driver for PL330"
> ? ? ? ?select DMA_ENGINE
> + ? ? ? select ARM_AMBA
> ? ? ? ?depends on PL330
> ? ? ? ?help
> ? ? ? ? ?Select if your platform has one or more PL330 DMACs.
> diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
> index 00eee59..fcad90c 100644
> --- a/drivers/dma/pl330.c
> +++ b/drivers/dma/pl330.c
> @@ -17,6 +17,7 @@
> ?#include <linux/interrupt.h>
> ?#include <linux/amba/bus.h>
> ?#include <linux/amba/pl330.h>
> +#include <linux/scatterlist.h>
>
> ?#define NR_DEFAULT_DESC ? ? ? ?16

Thanks!

This looks like a separate patch to activate the DMA driver,
this should probably go into -rc.

Linus Walleij

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

* [PATCH v4] amba: consolidate PrimeCell magic
  2011-08-18  7:58 Linus Walleij
  2011-08-18  8:43 ` Viresh Kumar
  2011-08-18 16:25 ` H Hartley Sweeten
@ 2011-08-19  5:24 ` Kukjin Kim
  2 siblings, 0 replies; 12+ messages in thread
From: Kukjin Kim @ 2011-08-19  5:24 UTC (permalink / raw)
  To: linux-arm-kernel

Linus Walleij wrote:
> 
> From: Linus Walleij <linus.walleij@linaro.org>
> 
> Since two drivers use the PrimeCell scheme without using the
> amba_bus driver logic, let's break the magic lookups out as
> static inlines in the <linux/amba/bus.h> header so we get
> some consolidation anyway. Delete the primecell ID check in
> common/pl330.c since it is only used from the amba_bus driver
> in drivers/dma, which is already doing the same check when
> probing in drivers/amba/bus.c.
> 
> Cc: Kukjin Kim <kgene.kim@samsung.com>
Acked-by: Kukjin Kim <kgene.kim@samsung.com>

> Cc: Viresh Kumar <viresh.kumar@st.com>
> Acked-by: H Hartley Sweeten <hartleys@visionengravers.com>
> Acked-by: Jassi Brar <jassisinghbrar@gmail.com>
> Acked-by: Boojin Kim <boojin.kim@samsung.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <kgene.kim@samsung.com>, Senior Engineer,
SW Solution Development Team, Samsung Electronics Co., Ltd.

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

* [PATCH v4] amba: consolidate PrimeCell magic
  2011-08-18  7:58 Linus Walleij
  2011-08-18  8:43 ` Viresh Kumar
@ 2011-08-18 16:25 ` H Hartley Sweeten
  2011-08-19  5:24 ` Kukjin Kim
  2 siblings, 0 replies; 12+ messages in thread
From: H Hartley Sweeten @ 2011-08-18 16:25 UTC (permalink / raw)
  To: linux-arm-kernel

On Thursday, August 18, 2011 12:59 AM, Linus Walleij wrote:
>
> Since two drivers use the PrimeCell scheme without using the
> amba_bus driver logic, let's break the magic lookups out as
> static inlines in the <linux/amba/bus.h> header so we get
> some consolidation anyway. Delete the primecell ID check in
> common/pl330.c since it is only used from the amba_bus driver
> in drivers/dma, which is already doing the same check when
> probing in drivers/amba/bus.c.
>
> Cc: Kukjin Kim <kgene.kim@samsung.com>
> Cc: Viresh Kumar <viresh.kumar@st.com>
> Acked-by: H Hartley Sweeten <hartleys@visionengravers.com>
> Acked-by: Jassi Brar <jassisinghbrar@gmail.com>
> Acked-by: Boojin Kim <boojin.kim@samsung.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> Changes V3->v4:
> - Fix up sparse warning due to inelegant cast to (u32) in vic.c,
>   we cast to (unsigned long) and sparse is happy.

Thanks!

One nit...

+	/*
+	 * Identify which VIC cell this one is, by reading the ID - some
+	 * implementations have two VICs in the same page but only one set
+	 * of ID registers at the end, so we need to adjust the base to
+	 * reference the page offset. All VIC:s are size 4K.
                                           ^

Is this supposed to be VIC's

Regards,
Hartley

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

* [PATCH v4] amba: consolidate PrimeCell magic
  2011-08-18  7:58 Linus Walleij
@ 2011-08-18  8:43 ` Viresh Kumar
  2011-08-18 16:25 ` H Hartley Sweeten
  2011-08-19  5:24 ` Kukjin Kim
  2 siblings, 0 replies; 12+ messages in thread
From: Viresh Kumar @ 2011-08-18  8:43 UTC (permalink / raw)
  To: linux-arm-kernel

On 8/18/2011 1:28 PM, Linus WALLEIJ wrote:
> From: Linus Walleij <linus.walleij@linaro.org>
> 
> Since two drivers use the PrimeCell scheme without using the
> amba_bus driver logic, let's break the magic lookups out as
> static inlines in the <linux/amba/bus.h> header so we get
> some consolidation anyway. Delete the primecell ID check in
> common/pl330.c since it is only used from the amba_bus driver
> in drivers/dma, which is already doing the same check when
> probing in drivers/amba/bus.c.
> 
> Cc: Kukjin Kim <kgene.kim@samsung.com>
> Cc: Viresh Kumar <viresh.kumar@st.com>
> Acked-by: H Hartley Sweeten <hartleys@visionengravers.com>
> Acked-by: Jassi Brar <jassisinghbrar@gmail.com>
> Acked-by: Boojin Kim <boojin.kim@samsung.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Good One!!

Acked-by: Viresh Kumar <viresh.kumar@st.com>

-- 
viresh

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

* [PATCH v4] amba: consolidate PrimeCell magic
@ 2011-08-18  7:58 Linus Walleij
  2011-08-18  8:43 ` Viresh Kumar
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Linus Walleij @ 2011-08-18  7:58 UTC (permalink / raw)
  To: linux-arm-kernel

From: Linus Walleij <linus.walleij@linaro.org>

Since two drivers use the PrimeCell scheme without using the
amba_bus driver logic, let's break the magic lookups out as
static inlines in the <linux/amba/bus.h> header so we get
some consolidation anyway. Delete the primecell ID check in
common/pl330.c since it is only used from the amba_bus driver
in drivers/dma, which is already doing the same check when
probing in drivers/amba/bus.c.

Cc: Kukjin Kim <kgene.kim@samsung.com>
Cc: Viresh Kumar <viresh.kumar@st.com>
Acked-by: H Hartley Sweeten <hartleys@visionengravers.com>
Acked-by: Jassi Brar <jassisinghbrar@gmail.com>
Acked-by: Boojin Kim <boojin.kim@samsung.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
Changes V3->v4:
- Fix up sparse warning due to inelegant cast to (u32) in vic.c,
  we cast to (unsigned long) and sparse is happy.
---
 arch/arm/common/pl330.c      |   40 +++-------------------------------------
 arch/arm/common/vic.c        |   15 ++++++++-------
 drivers/amba/bus.c           |   19 +++----------------
 drivers/dma/ste_dma40.c      |   14 ++++----------
 drivers/mtd/nand/fsmc_nand.c |   10 +++-------
 include/linux/amba/bus.h     |   26 ++++++++++++++++++++++++++
 6 files changed, 47 insertions(+), 77 deletions(-)

diff --git a/arch/arm/common/pl330.c b/arch/arm/common/pl330.c
index 97912fa..623ce74 100644
--- a/arch/arm/common/pl330.c
+++ b/arch/arm/common/pl330.c
@@ -27,6 +27,7 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/dma-mapping.h>
+#include <linux/amba/bus.h>
 
 #include <asm/hardware/pl330.h>
 
@@ -111,9 +112,6 @@
 #define CR4		0xe10
 #define CRD		0xe14
 
-#define PERIPH_ID	0xfe0
-#define PCELL_ID	0xff0
-
 #define CR0_PERIPH_REQ_SET	(1 << 0)
 #define CR0_BOOT_EN_SET		(1 << 1)
 #define CR0_BOOT_MAN_NS		(1 << 2)
@@ -142,14 +140,6 @@
 #define CRD_DATA_BUFF_SHIFT	20
 #define CRD_DATA_BUFF_MASK	0x3ff
 
-#define	PART		0x330
-#define DESIGNER	0x41
-#define REVISION	0x0
-#define INTEG_CFG	0x0
-#define PERIPH_ID_VAL	((PART << 0) | (DESIGNER << 12))
-
-#define PCELL_ID_VAL	0xb105f00d
-
 #define PL330_STATE_STOPPED		(1 << 0)
 #define PL330_STATE_EXECUTING		(1 << 1)
 #define PL330_STATE_WFE			(1 << 2)
@@ -372,19 +362,6 @@ static inline bool _manager_ns(struct pl330_thread *thrd)
 	return (pl330->pinfo->pcfg.mode & DMAC_MODE_NS) ? true : false;
 }
 
-static inline u32 get_id(struct pl330_info *pi, u32 off)
-{
-	void __iomem *regs = pi->base;
-	u32 id = 0;
-
-	id |= (readb(regs + off + 0x0) << 0);
-	id |= (readb(regs + off + 0x4) << 8);
-	id |= (readb(regs + off + 0x8) << 16);
-	id |= (readb(regs + off + 0xc) << 24);
-
-	return id;
-}
-
 static inline u32 _emit_ADDH(unsigned dry_run, u8 buf[],
 		enum pl330_dst da, u16 val)
 {
@@ -1747,8 +1724,8 @@ static void read_dmac_config(struct pl330_info *pi)
 
 	pi->pcfg.irq_ns = readl(regs + CR3);
 
-	pi->pcfg.periph_id = get_id(pi, PERIPH_ID);
-	pi->pcfg.pcell_id = get_id(pi, PCELL_ID);
+	pi->pcfg.periph_id = amba_get_pid(pi->base, PCELL_SIZE);
+	pi->pcfg.pcell_id = amba_get_cid(pi->base, PCELL_SIZE);
 }
 
 static inline void _reset_thread(struct pl330_thread *thrd)
@@ -1838,7 +1815,6 @@ static int dmac_alloc_resources(struct pl330_dmac *pl330)
 int pl330_add(struct pl330_info *pi)
 {
 	struct pl330_dmac *pl330;
-	void __iomem *regs;
 	int i, ret;
 
 	if (!pi || !pi->dev)
@@ -1855,16 +1831,6 @@ int pl330_add(struct pl330_info *pi)
 	if (pi->dmac_reset)
 		pi->dmac_reset(pi);
 
-	regs = pi->base;
-
-	/* Check if we can handle this DMAC */
-	if ((get_id(pi, PERIPH_ID) & 0xfffff) != PERIPH_ID_VAL
-	   || get_id(pi, PCELL_ID) != PCELL_ID_VAL) {
-		dev_err(pi->dev, "PERIPH_ID 0x%x, PCELL_ID 0x%x !\n",
-			get_id(pi, PERIPH_ID), get_id(pi, PCELL_ID));
-		return -EINVAL;
-	}
-
 	/* Read the configuration of the DMAC */
 	read_dmac_config(pi);
 
diff --git a/arch/arm/common/vic.c b/arch/arm/common/vic.c
index 7aa4262..84a51ea 100644
--- a/arch/arm/common/vic.c
+++ b/arch/arm/common/vic.c
@@ -341,16 +341,17 @@ static void __init vic_init_st(void __iomem *base, unsigned int irq_start,
 void __init vic_init(void __iomem *base, unsigned int irq_start,
 		     u32 vic_sources, u32 resume_sources)
 {
-	unsigned int i;
 	u32 cellid = 0;
 	enum amba_vendor vendor;
 
-	/* Identify which VIC cell this one is, by reading the ID */
-	for (i = 0; i < 4; i++) {
-		u32 addr = ((u32)base & PAGE_MASK) + 0xfe0 + (i * 4);
-		cellid |= (readl(addr) & 0xff) << (8 * i);
-	}
-	vendor = (cellid >> 12) & 0xff;
+	/*
+	 * Identify which VIC cell this one is, by reading the ID - some
+	 * implementations have two VICs in the same page but only one set
+	 * of ID registers at the end, so we need to adjust the base to
+	 * reference the page offset. All VIC:s are size 4K.
+	 */
+	cellid = amba_get_pid((void __iomem *)((unsigned long)base & PAGE_MASK), SZ_4K);
+	vendor = AMBA_MANF_BITS(cellid);
 	printk(KERN_INFO "VIC @%p: id 0x%08x, vendor 0x%02x\n",
 	       base, cellid, vendor);
 
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index d74926e..7412671 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -579,7 +579,7 @@ int amba_device_register(struct amba_device *dev, struct resource *parent)
 {
 	u32 size;
 	void __iomem *tmp;
-	int i, ret;
+	int ret;
 
 	device_initialize(&dev->dev);
 
@@ -620,24 +620,11 @@ int amba_device_register(struct amba_device *dev, struct resource *parent)
 
 	ret = amba_get_enable_pclk(dev);
 	if (ret == 0) {
-		u32 pid, cid;
-
-		/*
-		 * Read pid and cid based on size of resource
-		 * they are located at end of region
-		 */
-		for (pid = 0, i = 0; i < 4; i++)
-			pid |= (readl(tmp + size - 0x20 + 4 * i) & 255) <<
-				(i * 8);
-		for (cid = 0, i = 0; i < 4; i++)
-			cid |= (readl(tmp + size - 0x10 + 4 * i) & 255) <<
-				(i * 8);
+		if (amba_get_cid(tmp, size) == AMBA_CID)
+			dev->periphid = amba_get_pid(tmp, size);
 
 		amba_put_disable_pclk(dev);
 
-		if (cid == AMBA_CID)
-			dev->periphid = pid;
-
 		if (!dev->periphid)
 			ret = -ENODEV;
 	}
diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index cd3a7c7..6e11cef 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -2569,7 +2569,6 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
 	int num_phy_chans;
 	int i;
 	u32 pid;
-	u32 cid;
 	u8 rev;
 
 	clk = clk_get(&pdev->dev, NULL);
@@ -2594,18 +2593,13 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
 	if (!virtbase)
 		goto failure;
 
-	/* This is just a regular AMBA PrimeCell ID actually */
-	for (pid = 0, i = 0; i < 4; i++)
-		pid |= (readl(virtbase + resource_size(res) - 0x20 + 4 * i)
-			& 255) << (i * 8);
-	for (cid = 0, i = 0; i < 4; i++)
-		cid |= (readl(virtbase + resource_size(res) - 0x10 + 4 * i)
-			& 255) << (i * 8);
-
-	if (cid != AMBA_CID) {
+	/* Device ID use the AMBA PrimeCell scheme */
+	if (amba_get_cid(virtbase, resource_size(res)) != AMBA_CID) {
 		d40_err(&pdev->dev, "Unknown hardware! No PrimeCell ID\n");
 		goto failure;
 	}
+
+	pid = amba_get_pid(virtbase, resource_size(res));
 	if (AMBA_MANF_BITS(pid) != AMBA_VENDOR_ST) {
 		d40_err(&pdev->dev, "Unknown designer! Got %x wanted %x\n",
 			AMBA_MANF_BITS(pid),
diff --git a/drivers/mtd/nand/fsmc_nand.c b/drivers/mtd/nand/fsmc_nand.c
index e9b275a..836de62 100644
--- a/drivers/mtd/nand/fsmc_nand.c
+++ b/drivers/mtd/nand/fsmc_nand.c
@@ -541,8 +541,6 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
 	struct fsmc_regs *regs;
 	struct resource *res;
 	int ret = 0;
-	u32 pid;
-	int i;
 
 	if (!pdata) {
 		dev_err(&pdev->dev, "platform data is NULL\n");
@@ -636,13 +634,11 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
 	 * This device ID is actually a common AMBA ID as used on the
 	 * AMBA PrimeCell bus. However it is not a PrimeCell.
 	 */
-	for (pid = 0, i = 0; i < 4; i++)
-		pid |= (readl(host->regs_va + resource_size(res) - 0x20 + 4 * i) & 255) << (i * 8);
-	host->pid = pid;
+	host->pid = amba_get_pid(host->regs_va, resource_size(res));
 	dev_info(&pdev->dev, "FSMC device partno %03x, manufacturer %02x, "
 		 "revision %02x, config %02x\n",
-		 AMBA_PART_BITS(pid), AMBA_MANF_BITS(pid),
-		 AMBA_REV_BITS(pid), AMBA_CONFIG_BITS(pid));
+		 AMBA_PART_BITS(host->pid), AMBA_MANF_BITS(host->pid),
+		 AMBA_REV_BITS(host->pid), AMBA_CONFIG_BITS(host->pid));
 
 	host->bank = pdata->bank;
 	host->select_chip = pdata->select_bank;
diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h
index fcbbe71..008cfcf 100644
--- a/include/linux/amba/bus.h
+++ b/include/linux/amba/bus.h
@@ -19,6 +19,7 @@
 #include <linux/err.h>
 #include <linux/resource.h>
 #include <linux/regulator/consumer.h>
+#include <linux/io.h>
 
 #define AMBA_NR_IRQS	2
 #define AMBA_CID	0xb105f00d
@@ -94,4 +95,29 @@ void amba_release_regions(struct amba_device *);
 #define amba_manf(d)	AMBA_MANF_BITS((d)->periphid)
 #define amba_part(d)	AMBA_PART_BITS((d)->periphid)
 
+/*
+ * Inlines to extract the PID and CID for a certain PrimeCell. These are at
+ * offset -0x20 and -0x10 from the end of the I/O region respectively.
+ */
+static inline u32 amba_get_magic(void __iomem *base, u32 size, u8 offset)
+{
+	u32 magic;
+	int i;
+
+	for (magic = 0, i = 0; i < 4; i++)
+		magic |= (readl(base + size - offset + 4 * i) & 255)
+			<< (i * 8);
+	return magic;
+}
+
+static inline u32 amba_get_pid(void __iomem *base, u32 size)
+{
+	return amba_get_magic(base, size, 0x20);
+}
+
+static inline u32 amba_get_cid(void __iomem *base, u32 size)
+{
+	return amba_get_magic(base, size, 0x10);
+}
+
 #endif
-- 
1.7.3.2

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

end of thread, other threads:[~2011-08-22 12:20 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-18  6:43 [PATCH] ARM: S5P64X0: Add the devname for DMA clock Boojin Kim
2011-08-18  6:43 ` Boojin Kim
2011-08-19  5:24 ` Kukjin Kim
2011-08-19  5:24   ` Kukjin Kim
     [not found]   ` <001c01cc6082$123cef20$36b6cd60$%kim@samsung.com>
2011-08-22  4:41     ` [PATCH v4] amba: consolidate PrimeCell magic Boojin Kim
2011-08-22  7:11       ` Linus Walleij
2011-08-22 11:57         ` Boojin Kim
2011-08-22 12:20           ` Linus Walleij
2011-08-18  7:58 Linus Walleij
2011-08-18  8:43 ` Viresh Kumar
2011-08-18 16:25 ` H Hartley Sweeten
2011-08-19  5:24 ` Kukjin Kim

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.