Re: [RFC][PATCH 1/2] S5PV210: SPI: Add clkdev support

2011-08-10 Thread padma venkat
Hi Sylwester,

On Tue, Aug 9, 2011 at 7:12 PM, Sylwester Nawrocki
s.nawro...@samsung.com wrote:
 [corrected Jassi's email address]

 On 08/09/2011 03:57 PM, Padmavathi Venna wrote:
 Create a clkdev alias for spi bus clock and modify the spi
 driver to lookup the clock using the alias name instead of
 passing clock name and clock number from SPI platform data.

 Signed-off-by: Padmavathi Venna padm...@samsung.com
 ---
 This patch is tested for S5PV210 platform and similar
 changes can be adopted for rest of the Samsung's s3c
 and s5p platforms, if this approach is accepted.

 It is a bit surprising to me how you do intend to use the clock aliases.
 Are we seriously going to be creating clock con_id aliases for most
 of the available devices ? It doesn't sound sane to me..
We don't need to create the alias names for all the devices. But we need
to create only for those which need clock information from platform data.
As far as I know we need to create for spi,hsmmc,uart and iis.

 Wouldn't it be possible to avoid the aliases by correcting the clock
 registration process ?
Yes it is possible but we don't have the flexibility to create the alias names
only for the required clocks.

  arch/arm/mach-s5pv210/dev-spi.c                  |   31 
 ++---
  arch/arm/plat-samsung/include/plat/s3c64xx-spi.h |    7 +
  2 files changed, 27 insertions(+), 11 deletions(-)

 diff --git a/arch/arm/mach-s5pv210/dev-spi.c 
 b/arch/arm/mach-s5pv210/dev-spi.c
 ...
 -void __init s5pv210_spi_set_info(int cntrlr, int src_clk_nr, int num_cs)
 +void __init s5pv210_spi_set_info(int cntrlr, int num_cs)
  {
       struct s3c64xx_spi_info *pd;
 +     struct device *dev;
 +     char devname[16], clk_alias_name[16];
 +     int ret, i;

       /* Reject invalid configuration */
 -     if (!num_cs || src_clk_nr  0
 -                     || src_clk_nr  S5PV210_SPI_SRCCLK_SCLK) {
 +     if (!num_cs) {
               printk(KERN_ERR %s: Invalid SPI configuration\n, __func__);
               return;
       }
 @@ -159,9 +162,11 @@ void __init s5pv210_spi_set_info(int cntrlr, int 
 src_clk_nr, int num_cs)
       switch (cntrlr) {
       case 0:
               pd = s5pv210_spi0_pdata;
 +             dev = s5pv210_device_spi0.dev;
               break;
       case 1:
               pd = s5pv210_spi1_pdata;
 +             dev = s5pv210_device_spi1.dev;
               break;
       default:
               printk(KERN_ERR %s: Invalid SPI controller(%d)\n,
 @@ -169,7 +174,23 @@ void __init s5pv210_spi_set_info(int cntrlr, int 
 src_clk_nr, int num_cs)
               return;
       }

 +     sprintf(devname, s3c64xx-spi.%d, cntrlr);
 +
 +     for (i = 0; i  ARRAY_SIZE(spi_src_clks); i++) {
 +             sprintf(clk_alias_name, clk_spi_bus%d, i);
 +
 +             if (!strcmp(spi_src_clks[i], pclk))
 +                     ret = clk_add_alias(clk_alias_name, devname,
 +                                             spi_src_clks[i], NULL);
 +             else
 +                     ret = clk_add_alias(clk_alias_name, devname,
 +                                             spi_src_clks[i], dev);
 +             if (ret) {
 +                     printk(KERN_ERR failed to create alias for
 +                              SPI%d source clock%d\n, cntrlr, i);
 +                     continue;
 +             }
 +     }
 +
       pd-num_cs = num_cs;
 -     pd-src_clk_nr = src_clk_nr;
 -     pd-src_clk_name = spi_src_clks[src_clk_nr];
  }
 ...

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

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


Re: [RFC][PATCH 1/2] S5PV210: SPI: Add clkdev support

2011-08-10 Thread Sylwester Nawrocki
Hi Padmavathi,

On 08/10/2011 02:04 PM, padma venkat wrote:
 Hi Sylwester,
 
 On Tue, Aug 9, 2011 at 7:12 PM, Sylwester Nawrocki
 s.nawro...@samsung.com wrote:
 [corrected Jassi's email address]

 On 08/09/2011 03:57 PM, Padmavathi Venna wrote:
 Create a clkdev alias for spi bus clock and modify the spi
 driver to lookup the clock using the alias name instead of
 passing clock name and clock number from SPI platform data.

 Signed-off-by: Padmavathi Venna padm...@samsung.com
 ---
 This patch is tested for S5PV210 platform and similar
 changes can be adopted for rest of the Samsung's s3c
 and s5p platforms, if this approach is accepted.

 It is a bit surprising to me how you do intend to use the clock aliases.
 Are we seriously going to be creating clock con_id aliases for most
 of the available devices ? It doesn't sound sane to me..

 We don't need to create the alias names for all the devices. But we need
 to create only for those which need clock information from platform data.
 As far as I know we need to create for spi,hsmmc,uart and iis.

That's already a lot. 
Just to clarify, the clock names were originally passed in platform_data
because they differ across SoCs the driver supports, right ?
Or are there any other reasons ?

The whole idea of the clkdev is not to require any information about 
the clocks in platform_data. You just need to be registering the clock 
identifiers *at the device*, not the clock names specific to the machine.
The platform code takes care of the translation and the drivers only need
to ask clkdev for the 'clock connection id', rather than the original
machine clock name.
You can do this by adding the aliases, but it's not optimal. You are adding
the code which could well be avoided.



 Wouldn't it be possible to avoid the aliases by correcting the clock
 registration process ?

 Yes it is possible but we don't have the flexibility to create the alias names
 only for the required clocks.

By registering proper clock connection ids you would not need the aliases at 
all.

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


[RFC][PATCH 1/2] S5PV210: SPI: Add clkdev support

2011-08-09 Thread Padmavathi Venna
Create a clkdev alias for spi bus clock and modify the spi
driver to lookup the clock using the alias name instead of
passing clock name and clock number from SPI platform data.

Signed-off-by: Padmavathi Venna padm...@samsung.com
---
This patch is tested for S5PV210 platform and similar
changes can be adopted for rest of the Samsung's s3c
and s5p platforms, if this approach is accepted.

 arch/arm/mach-s5pv210/dev-spi.c  |   31 ++---
 arch/arm/plat-samsung/include/plat/s3c64xx-spi.h |7 +
 2 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-s5pv210/dev-spi.c b/arch/arm/mach-s5pv210/dev-spi.c
index eaf9a7b..e81b67d 100644
--- a/arch/arm/mach-s5pv210/dev-spi.c
+++ b/arch/arm/mach-s5pv210/dev-spi.c
@@ -11,6 +11,7 @@
 #include linux/platform_device.h
 #include linux/dma-mapping.h
 #include linux/gpio.h
+#include linux/clk.h
 
 #include mach/dma.h
 #include mach/map.h
@@ -145,13 +146,15 @@ struct platform_device s5pv210_device_spi1 = {
},
 };
 
-void __init s5pv210_spi_set_info(int cntrlr, int src_clk_nr, int num_cs)
+void __init s5pv210_spi_set_info(int cntrlr, int num_cs)
 {
struct s3c64xx_spi_info *pd;
+   struct device *dev;
+   char devname[16], clk_alias_name[16];
+   int ret, i;
 
/* Reject invalid configuration */
-   if (!num_cs || src_clk_nr  0
-   || src_clk_nr  S5PV210_SPI_SRCCLK_SCLK) {
+   if (!num_cs) {
printk(KERN_ERR %s: Invalid SPI configuration\n, __func__);
return;
}
@@ -159,9 +162,11 @@ void __init s5pv210_spi_set_info(int cntrlr, int 
src_clk_nr, int num_cs)
switch (cntrlr) {
case 0:
pd = s5pv210_spi0_pdata;
+   dev = s5pv210_device_spi0.dev;
break;
case 1:
pd = s5pv210_spi1_pdata;
+   dev = s5pv210_device_spi1.dev;
break;
default:
printk(KERN_ERR %s: Invalid SPI controller(%d)\n,
@@ -169,7 +174,23 @@ void __init s5pv210_spi_set_info(int cntrlr, int 
src_clk_nr, int num_cs)
return;
}
 
+   sprintf(devname, s3c64xx-spi.%d, cntrlr);
+
+   for (i = 0; i  ARRAY_SIZE(spi_src_clks); i++) {
+   sprintf(clk_alias_name, clk_spi_bus%d, i);
+
+   if (!strcmp(spi_src_clks[i], pclk))
+   ret = clk_add_alias(clk_alias_name, devname,
+   spi_src_clks[i], NULL);
+   else
+   ret = clk_add_alias(clk_alias_name, devname,
+   spi_src_clks[i], dev);
+   if (ret) {
+   printk(KERN_ERR failed to create alias for
+SPI%d source clock%d\n, cntrlr, i);
+   continue;
+   }
+   }
+
pd-num_cs = num_cs;
-   pd-src_clk_nr = src_clk_nr;
-   pd-src_clk_name = spi_src_clks[src_clk_nr];
 }
diff --git a/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h 
b/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h
index 4c16fa3..70ddd8c 100644
--- a/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h
+++ b/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h
@@ -30,8 +30,6 @@ struct s3c64xx_spi_csinfo {
 
 /**
  * struct s3c64xx_spi_info - SPI Controller defining structure
- * @src_clk_nr: Clock source index for the CLK_CFG[SPI_CLKSEL] field.
- * @src_clk_name: Platform name of the corresponding clock.
  * @clk_from_cmu: If the SPI clock/prescalar control block is present
  * by the platform's clock-management-unit and not in SPI controller.
  * @num_cs: Number of CS this controller emulates.
@@ -42,8 +40,6 @@ struct s3c64xx_spi_csinfo {
  * @tx_st_done: Depends on tx fifo_lvl field
  */
 struct s3c64xx_spi_info {
-   int src_clk_nr;
-   char *src_clk_name;
bool clk_from_cmu;
 
int num_cs;
@@ -61,7 +57,6 @@ struct s3c64xx_spi_info {
  * s3c64xx_spi_set_info - SPI Controller configure callback by the board
  * initialization code.
  * @cntrlr: SPI controller number the configuration is for.
- * @src_clk_nr: Clock the SPI controller is to use to generate SPI clocks.
  * @num_cs: Number of elements in the 'cs' array.
  *
  * Call this from machine init code for each SPI Controller that
@@ -69,7 +64,7 @@ struct s3c64xx_spi_info {
  */
 extern void s3c64xx_spi_set_info(int cntrlr, int src_clk_nr, int num_cs);
 extern void s5pc100_spi_set_info(int cntrlr, int src_clk_nr, int num_cs);
-extern void s5pv210_spi_set_info(int cntrlr, int src_clk_nr, int num_cs);
+extern void s5pv210_spi_set_info(int cntrlr, int num_cs);
 extern void s5p64x0_spi_set_info(int cntrlr, int src_clk_nr, int num_cs);
 
 #endif /* __S3C64XX_PLAT_SPI_H */
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info