Re: [PATCH 1/4] mmc: sdhci-s3c: use the sdhci-pltfm for Samsung-SoC

2012-02-24 Thread Thomas Abraham
Dear Mr. Chung,

This has been in the todo list for a long time. Thanks for the patch.
With the use of device tree and sdhci-pltfm driver, it should be
possible to avoid dependency with platform code.

There are few comments below.

On 14 February 2012 10:33, Jaehoon Chung jh80.ch...@samsung.com wrote:
 This patch is change to use the sdhci-pltfm.c

 Signed-off-by: Jaehoon Chung jh80.ch...@samsung.com
 signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
 ---
  drivers/mmc/host/sdhci-s3c.c |  218 
 ++
  1 files changed, 71 insertions(+), 147 deletions(-)

 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
 index 1af756e..a651c1e 100644
 --- a/drivers/mmc/host/sdhci-s3c.c
 +++ b/drivers/mmc/host/sdhci-s3c.c
 @@ -26,6 +26,7 @@
  #include plat/sdhci.h
  #include plat/regs-sdhci.h

 +#include sdhci-pltfm.h
  #include sdhci.h

  #define MAX_BUS_CLK    (4)
 @@ -41,9 +42,7 @@
  * @clk_bus: The clocks that are available for the SD/MMC bus clock.
  */
  struct sdhci_s3c {
 -       struct sdhci_host       *host;
        struct platform_device  *pdev;
 -       struct resource         *ioarea;
        struct s3c_sdhci_platdata *pdata;
        unsigned int            cur_clk;

Would it be possible to remove cur_clk and only use pltfm_host-clk ?

        int                     ext_cd_irq;
 @@ -53,11 +52,6 @@ struct sdhci_s3c {
        struct clk              *clk_bus[MAX_BUS_CLK];
  };

 -static inline struct sdhci_s3c *to_s3c(struct sdhci_host *host)
 -{
 -       return sdhci_priv(host);
 -}
 -
  /**
  * get_curclk - convert ctrl2 register to clock source number
  * @ctrl2: Control2 register value.
 @@ -72,7 +66,8 @@ static u32 get_curclk(u32 ctrl2)

  static void sdhci_s3c_check_sclk(struct sdhci_host *host)
  {
 -       struct sdhci_s3c *ourhost = to_s3c(host);
 +       struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 +       struct sdhci_s3c *ourhost = pltfm_host-priv;
        u32 tmp = readl(host-ioaddr + S3C_SDHCI_CONTROL2);

        if (get_curclk(tmp) != ourhost-cur_clk) {
 @@ -92,13 +87,13 @@ static void sdhci_s3c_check_sclk(struct sdhci_host *host)
  */
  static unsigned int sdhci_s3c_get_max_clk(struct sdhci_host *host)
  {
 -       struct sdhci_s3c *ourhost = to_s3c(host);
 +       struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 +       struct sdhci_s3c *ourhost = pltfm_host-priv;
        struct clk *busclk;
        unsigned int rate, max;
        int clk;

        /* note, a reset will reset the clock source */
 -
        sdhci_s3c_check_sclk(host);

        for (max = 0, clk = 0; clk  MAX_BUS_CLK; clk++) {
 @@ -163,7 +158,8 @@ static unsigned int sdhci_s3c_consider_clock(struct 
 sdhci_s3c *ourhost,
  */
  static void sdhci_s3c_set_clock(struct sdhci_host *host, unsigned int clock)
  {
 -       struct sdhci_s3c *ourhost = to_s3c(host);
 +       struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 +       struct sdhci_s3c *ourhost = pltfm_host-priv;
        unsigned int best = UINT_MAX;
        unsigned int delta;
        int best_src = 0;
 @@ -233,7 +229,8 @@ static void sdhci_s3c_set_clock(struct sdhci_host *host, 
 unsigned int clock)
  */
  static unsigned int sdhci_s3c_get_min_clock(struct sdhci_host *host)
  {
 -       struct sdhci_s3c *ourhost = to_s3c(host);
 +       struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 +       struct sdhci_s3c *ourhost = pltfm_host-priv;
        unsigned int delta, min = UINT_MAX;
        int src;

 @@ -251,27 +248,27 @@ static unsigned int sdhci_s3c_get_min_clock(struct 
 sdhci_host *host)
  /* sdhci_cmu_get_max_clk - callback to get maximum clock frequency.*/
  static unsigned int sdhci_cmu_get_max_clock(struct sdhci_host *host)
  {
 -       struct sdhci_s3c *ourhost = to_s3c(host);
 +       struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);

 -       return clk_round_rate(ourhost-clk_bus[ourhost-cur_clk], UINT_MAX);
 +       return clk_round_rate(pltfm_host-clk, UINT_MAX);
  }

  /* sdhci_cmu_get_min_clock - callback to get minimal supported clock value. 
 */
  static unsigned int sdhci_cmu_get_min_clock(struct sdhci_host *host)
  {
 -       struct sdhci_s3c *ourhost = to_s3c(host);
 +       struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);

        /*
         * initial clock can be in the frequency range of
         * 100KHz-400KHz, so we set it as max value.
         */
 -       return clk_round_rate(ourhost-clk_bus[ourhost-cur_clk], 40);
 +       return clk_round_rate(pltfm_host-clk, 40);
  }

  /* sdhci_cmu_set_clock - callback on clock change.*/
  static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int clock)
  {
 -       struct sdhci_s3c *ourhost = to_s3c(host);
 +       struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);

        /* don't bother if the clock is going off */
        if (clock == 0)
 @@ -279,7 +276,7 @@ static void sdhci_cmu_set_clock(struct sdhci_host *host, 
 unsigned int clock)

        

Re: [PATCH 1/4] mmc: sdhci-s3c: use the sdhci-pltfm for Samsung-SoC

2012-02-24 Thread Jaehoon Chung
On 02/24/2012 06:53 PM, Thomas Abraham wrote:

 Dear Mr. Chung,
 
 This has been in the todo list for a long time. Thanks for the patch.
 With the use of device tree and sdhci-pltfm driver, it should be
 possible to avoid dependency with platform code.

I'm working for using sdhci-pltfm. And in mmc-next tree, latest your patch is 
merged.
(using device-tree). So i rework this patch.
Right. this is the todo list. And need more discussion.
Main goal is to use the sdhci-pltfm.

 
 There are few comments below.
 
 On 14 February 2012 10:33, Jaehoon Chung jh80.ch...@samsung.com wrote:
 This patch is change to use the sdhci-pltfm.c

 Signed-off-by: Jaehoon Chung jh80.ch...@samsung.com
 signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
 ---
  drivers/mmc/host/sdhci-s3c.c |  218 
 ++
  1 files changed, 71 insertions(+), 147 deletions(-)

 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
 index 1af756e..a651c1e 100644
 --- a/drivers/mmc/host/sdhci-s3c.c
 +++ b/drivers/mmc/host/sdhci-s3c.c
 @@ -26,6 +26,7 @@
  #include plat/sdhci.h
  #include plat/regs-sdhci.h

 +#include sdhci-pltfm.h
  #include sdhci.h

  #define MAX_BUS_CLK(4)
 @@ -41,9 +42,7 @@
  * @clk_bus: The clocks that are available for the SD/MMC bus clock.
  */
  struct sdhci_s3c {
 -   struct sdhci_host   *host;
struct platform_device  *pdev;
 -   struct resource *ioarea;
struct s3c_sdhci_platdata *pdata;
unsigned intcur_clk;
 
 Would it be possible to remove cur_clk and only use pltfm_host-clk ?

Good point, cur_clk can be removed.

 
int ext_cd_irq;
 @@ -53,11 +52,6 @@ struct sdhci_s3c {
struct clk  *clk_bus[MAX_BUS_CLK];
  };

 -static inline struct sdhci_s3c *to_s3c(struct sdhci_host *host)
 -{
 -   return sdhci_priv(host);
 -}
 -
  /**
  * get_curclk - convert ctrl2 register to clock source number
  * @ctrl2: Control2 register value.
 @@ -72,7 +66,8 @@ static u32 get_curclk(u32 ctrl2)

  static void sdhci_s3c_check_sclk(struct sdhci_host *host)
  {
 -   struct sdhci_s3c *ourhost = to_s3c(host);
 +   struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 +   struct sdhci_s3c *ourhost = pltfm_host-priv;
u32 tmp = readl(host-ioaddr + S3C_SDHCI_CONTROL2);

if (get_curclk(tmp) != ourhost-cur_clk) {
 @@ -92,13 +87,13 @@ static void sdhci_s3c_check_sclk(struct sdhci_host *host)
  */
  static unsigned int sdhci_s3c_get_max_clk(struct sdhci_host *host)
  {
 -   struct sdhci_s3c *ourhost = to_s3c(host);
 +   struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 +   struct sdhci_s3c *ourhost = pltfm_host-priv;
struct clk *busclk;
unsigned int rate, max;
int clk;

/* note, a reset will reset the clock source */
 -
sdhci_s3c_check_sclk(host);

for (max = 0, clk = 0; clk  MAX_BUS_CLK; clk++) {
 @@ -163,7 +158,8 @@ static unsigned int sdhci_s3c_consider_clock(struct 
 sdhci_s3c *ourhost,
  */
  static void sdhci_s3c_set_clock(struct sdhci_host *host, unsigned int clock)
  {
 -   struct sdhci_s3c *ourhost = to_s3c(host);
 +   struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 +   struct sdhci_s3c *ourhost = pltfm_host-priv;
unsigned int best = UINT_MAX;
unsigned int delta;
int best_src = 0;
 @@ -233,7 +229,8 @@ static void sdhci_s3c_set_clock(struct sdhci_host *host, 
 unsigned int clock)
  */
  static unsigned int sdhci_s3c_get_min_clock(struct sdhci_host *host)
  {
 -   struct sdhci_s3c *ourhost = to_s3c(host);
 +   struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 +   struct sdhci_s3c *ourhost = pltfm_host-priv;
unsigned int delta, min = UINT_MAX;
int src;

 @@ -251,27 +248,27 @@ static unsigned int sdhci_s3c_get_min_clock(struct 
 sdhci_host *host)
  /* sdhci_cmu_get_max_clk - callback to get maximum clock frequency.*/
  static unsigned int sdhci_cmu_get_max_clock(struct sdhci_host *host)
  {
 -   struct sdhci_s3c *ourhost = to_s3c(host);
 +   struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);

 -   return clk_round_rate(ourhost-clk_bus[ourhost-cur_clk], UINT_MAX);
 +   return clk_round_rate(pltfm_host-clk, UINT_MAX);
  }

  /* sdhci_cmu_get_min_clock - callback to get minimal supported clock value. 
 */
  static unsigned int sdhci_cmu_get_min_clock(struct sdhci_host *host)
  {
 -   struct sdhci_s3c *ourhost = to_s3c(host);
 +   struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);

/*
 * initial clock can be in the frequency range of
 * 100KHz-400KHz, so we set it as max value.
 */
 -   return clk_round_rate(ourhost-clk_bus[ourhost-cur_clk], 40);
 +   return clk_round_rate(pltfm_host-clk, 40);
  }

  /* sdhci_cmu_set_clock - callback on clock change.*/
  static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int clock)
  {
 -