diff mbox

[1/7,V5] EXYNOS: CLK: Add i2c clock

Message ID 1341489592-24243-2-git-send-email-rajeshwari.s@samsung.com
State New
Headers show

Commit Message

Rajeshwari Shinde July 5, 2012, 11:59 a.m. UTC
This adds i2c clock information for EXYNOS5.

Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com>
Acked-by: Simon Glass <sjg@chromium.org>
---
changes in V2:
        - Incorporated comments from Simon Glass which are removed extra
          braces around (readl(&clk->div_top1)) >> 24 and gave a tab space for
          return statement.
Changes in V3:
        - None
Changes in V4:
        - None
Changes in V5:
        - None.
 arch/arm/cpu/armv7/exynos/clock.c      |   33 ++++++++++++++++++++++++++++++++
 arch/arm/include/asm/arch-exynos/clk.h |    1 +
 2 files changed, 34 insertions(+), 0 deletions(-)

Comments

Simon Glass July 18, 2012, 5:16 p.m. UTC | #1
Hi,

On Thu, Jul 5, 2012 at 12:59 PM, Rajeshwari Shinde
<rajeshwari.s@samsung.com> wrote:
> This adds i2c clock information for EXYNOS5.
>
> Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com>
> Signed-off-by: Doug Anderson <dianders@chromium.org>
> Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com>
> Acked-by: Simon Glass <sjg@chromium.org>

Sorry for late comments. Please see below for some nits.

Also I get these warnings with the samsung/master branch at present:

clock.c: In function 'get_pll_clk':
clock.c:178:6: warning: 'fout_sel' may be used uninitialized in this
function [-Wmaybe-uninitialized]
clock.c:101:35: note: 'fout_sel' was declared here
pinmux.c: In function 'exynos_pinmux_config':
pinmux.c:100:20: warning: 'gpio_func' may be used uninitialized in
this function [-Wmaybe-uninitialized]
pinmux.c:69:16: note: 'gpio_func' was declared here
pinmux.c:99:3: warning: 'start' may be used uninitialized in this
function [-Wmaybe-uninitialized]
pinmux.c:69:9: note: 'start' was declared here
clock.c: In function 'get_pll_clk':
clock.c:178:6: warning: 'fout_sel' may be used uninitialized in this
function [-Wmaybe-uninitialized]
clock.c:101:35: note: 'fout_sel' was declared here
pinmux.c: In function 'exynos_pinmux_config':
pinmux.c:100:20: warning: 'gpio_func' may be used uninitialized in
this function [-Wmaybe-uninitialized]
pinmux.c:69:16: note: 'gpio_func' was declared here
pinmux.c:99:3: warning: 'start' may be used uninitialized in this
function [-Wmaybe-uninitialized]
pinmux.c:69:9: note: 'start' was declared here


> ---
> changes in V2:
>         - Incorporated comments from Simon Glass which are removed extra
>           braces around (readl(&clk->div_top1)) >> 24 and gave a tab space for
>           return statement.
> Changes in V3:
>         - None
> Changes in V4:
>         - None
> Changes in V5:
>         - None.
>  arch/arm/cpu/armv7/exynos/clock.c      |   33 ++++++++++++++++++++++++++++++++
>  arch/arm/include/asm/arch-exynos/clk.h |    1 +
>  2 files changed, 34 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/cpu/armv7/exynos/clock.c b/arch/arm/cpu/armv7/exynos/clock.c
> index fc0ed5e..83ee25e 100644
> --- a/arch/arm/cpu/armv7/exynos/clock.c
> +++ b/arch/arm/cpu/armv7/exynos/clock.c
> @@ -602,6 +602,29 @@ void exynos4_set_mipi_clk(void)
>         writel(cfg, &clk->div_lcd0);
>  }
>
> +/*
> + * I2C
> + *
> + * exynos5: obtaining the I2C clock
> + */
> +static unsigned long exynos5_get_i2c_clk(void)
> +{
> +       struct exynos5_clock *clk =
> +               (struct exynos5_clock *)samsung_get_base_clock();
> +       unsigned long aclk_66, aclk_66_pre, sclk;
> +       unsigned int ratio;
> +
> +       sclk = get_pll_clk(MPLL);
> +
> +       ratio = (readl(&clk->div_top1)) >> 24;
> +       ratio &= (0x7);

Don't really need the ()

> +       aclk_66_pre = sclk/(ratio+1);

spaces around operators, and below

> +       ratio = readl(&clk->div_top0);
> +       ratio &= (0x7);
> +       aclk_66 = aclk_66_pre/(ratio+1);
> +       return aclk_66;
> +}
> +
>  unsigned long get_pll_clk(int pllreg)
>  {
>         if (cpu_is_exynos5())
> @@ -618,6 +641,16 @@ unsigned long get_arm_clk(void)
>                 return exynos4_get_arm_clk();
>  }
>
> +unsigned long get_i2c_clk(void)
> +{
> +       if (cpu_is_exynos5()) {
> +               return exynos5_get_i2c_clk();
> +       } else {
> +               debug("I2C clock is not set for this CPU\n");
> +               return 0;
> +       }
> +}
> +
>  unsigned long get_pwm_clk(void)
>  {
>         if (cpu_is_exynos5())
> diff --git a/arch/arm/include/asm/arch-exynos/clk.h b/arch/arm/include/asm/arch-exynos/clk.h
> index e99339a..5529025 100644
> --- a/arch/arm/include/asm/arch-exynos/clk.h
> +++ b/arch/arm/include/asm/arch-exynos/clk.h
> @@ -31,6 +31,7 @@
>
>  unsigned long get_pll_clk(int pllreg);
>  unsigned long get_arm_clk(void);
> +unsigned long get_i2c_clk(void);
>  unsigned long get_pwm_clk(void);
>  unsigned long get_uart_clk(int dev_index);
>  void set_mmc_clk(int dev_index, unsigned int div);
> --
> 1.7.4.4
>

Regards,
Simon
Rajeshwari Birje July 19, 2012, 6:01 a.m. UTC | #2
Hi Simon Glass,

Thank you for comments.

On Wed, Jul 18, 2012 at 10:46 PM, Simon Glass <sjg@chromium.org> wrote:
> Hi,
>
> On Thu, Jul 5, 2012 at 12:59 PM, Rajeshwari Shinde
> <rajeshwari.s@samsung.com> wrote:
>> This adds i2c clock information for EXYNOS5.
>>
>> Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com>
>> Signed-off-by: Doug Anderson <dianders@chromium.org>
>> Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com>
>> Acked-by: Simon Glass <sjg@chromium.org>
>
> Sorry for late comments. Please see below for some nits.
>
> Also I get these warnings with the samsung/master branch at present:
>
> clock.c: In function 'get_pll_clk':
> clock.c:178:6: warning: 'fout_sel' may be used uninitialized in this
> function [-Wmaybe-uninitialized]
> clock.c:101:35: note: 'fout_sel' was declared here
> pinmux.c: In function 'exynos_pinmux_config':
> pinmux.c:100:20: warning: 'gpio_func' may be used uninitialized in
> this function [-Wmaybe-uninitialized]
> pinmux.c:69:16: note: 'gpio_func' was declared here
> pinmux.c:99:3: warning: 'start' may be used uninitialized in this
> function [-Wmaybe-uninitialized]
> pinmux.c:69:9: note: 'start' was declared here
> clock.c: In function 'get_pll_clk':
> clock.c:178:6: warning: 'fout_sel' may be used uninitialized in this
> function [-Wmaybe-uninitialized]
> clock.c:101:35: note: 'fout_sel' was declared here
> pinmux.c: In function 'exynos_pinmux_config':
> pinmux.c:100:20: warning: 'gpio_func' may be used uninitialized in
> this function [-Wmaybe-uninitialized]
> pinmux.c:69:16: note: 'gpio_func' was declared here
> pinmux.c:99:3: warning: 'start' may be used uninitialized in this
> function [-Wmaybe-uninitialized]
> pinmux.c:69:9: note: 'start' was declared here
>
>
-- Sorry for inconvenience.. will correct them
>> ---
>> changes in V2:
>>         - Incorporated comments from Simon Glass which are removed extra
>>           braces around (readl(&clk->div_top1)) >> 24 and gave a tab space for
>>           return statement.
>> Changes in V3:
>>         - None
>> Changes in V4:
>>         - None
>> Changes in V5:
>>         - None.
>>  arch/arm/cpu/armv7/exynos/clock.c      |   33 ++++++++++++++++++++++++++++++++
>>  arch/arm/include/asm/arch-exynos/clk.h |    1 +
>>  2 files changed, 34 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm/cpu/armv7/exynos/clock.c b/arch/arm/cpu/armv7/exynos/clock.c
>> index fc0ed5e..83ee25e 100644
>> --- a/arch/arm/cpu/armv7/exynos/clock.c
>> +++ b/arch/arm/cpu/armv7/exynos/clock.c
>> @@ -602,6 +602,29 @@ void exynos4_set_mipi_clk(void)
>>         writel(cfg, &clk->div_lcd0);
>>  }
>>
>> +/*
>> + * I2C
>> + *
>> + * exynos5: obtaining the I2C clock
>> + */
>> +static unsigned long exynos5_get_i2c_clk(void)
>> +{
>> +       struct exynos5_clock *clk =
>> +               (struct exynos5_clock *)samsung_get_base_clock();
>> +       unsigned long aclk_66, aclk_66_pre, sclk;
>> +       unsigned int ratio;
>> +
>> +       sclk = get_pll_clk(MPLL);
>> +
>> +       ratio = (readl(&clk->div_top1)) >> 24;
>> +       ratio &= (0x7);
>
> Don't really need the ()
-- ok.
>
>> +       aclk_66_pre = sclk/(ratio+1);
>
> spaces around operators, and below
-- will correct this.
>
>> +       ratio = readl(&clk->div_top0);
>> +       ratio &= (0x7);
>> +       aclk_66 = aclk_66_pre/(ratio+1);
>> +       return aclk_66;
>> +}
>> +
>>  unsigned long get_pll_clk(int pllreg)
>>  {
>>         if (cpu_is_exynos5())
>> @@ -618,6 +641,16 @@ unsigned long get_arm_clk(void)
>>                 return exynos4_get_arm_clk();
>>  }
>>
>> +unsigned long get_i2c_clk(void)
>> +{
>> +       if (cpu_is_exynos5()) {
>> +               return exynos5_get_i2c_clk();
>> +       } else {
>> +               debug("I2C clock is not set for this CPU\n");
>> +               return 0;
>> +       }
>> +}
>> +
>>  unsigned long get_pwm_clk(void)
>>  {
>>         if (cpu_is_exynos5())
>> diff --git a/arch/arm/include/asm/arch-exynos/clk.h b/arch/arm/include/asm/arch-exynos/clk.h
>> index e99339a..5529025 100644
>> --- a/arch/arm/include/asm/arch-exynos/clk.h
>> +++ b/arch/arm/include/asm/arch-exynos/clk.h
>> @@ -31,6 +31,7 @@
>>
>>  unsigned long get_pll_clk(int pllreg);
>>  unsigned long get_arm_clk(void);
>> +unsigned long get_i2c_clk(void);
>>  unsigned long get_pwm_clk(void);
>>  unsigned long get_uart_clk(int dev_index);
>>  void set_mmc_clk(int dev_index, unsigned int div);
>> --
>> 1.7.4.4
>>
>
> Regards,
> Simon
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
Rajeshwari Birje July 19, 2012, 7:20 a.m. UTC | #3
Hi Simon Glass,

The warning messages are fixed in following patch:
"[PATCH] ARM: EXYNOS: fixed compiler warning message"
They are applied to u-boot today by Minkyu Kang.

Thanks and Regards,
Rajeshwari Shinde.

On Thu, Jul 19, 2012 at 11:31 AM, Rajeshwari Birje
<rajeshwari.birje@gmail.com> wrote:
> Hi Simon Glass,
>
> Thank you for comments.
>
> On Wed, Jul 18, 2012 at 10:46 PM, Simon Glass <sjg@chromium.org> wrote:
>> Hi,
>>
>> On Thu, Jul 5, 2012 at 12:59 PM, Rajeshwari Shinde
>> <rajeshwari.s@samsung.com> wrote:
>>> This adds i2c clock information for EXYNOS5.
>>>
>>> Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com>
>>> Signed-off-by: Doug Anderson <dianders@chromium.org>
>>> Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com>
>>> Acked-by: Simon Glass <sjg@chromium.org>
>>
>> Sorry for late comments. Please see below for some nits.
>>
>> Also I get these warnings with the samsung/master branch at present:
>>
>> clock.c: In function 'get_pll_clk':
>> clock.c:178:6: warning: 'fout_sel' may be used uninitialized in this
>> function [-Wmaybe-uninitialized]
>> clock.c:101:35: note: 'fout_sel' was declared here
>> pinmux.c: In function 'exynos_pinmux_config':
>> pinmux.c:100:20: warning: 'gpio_func' may be used uninitialized in
>> this function [-Wmaybe-uninitialized]
>> pinmux.c:69:16: note: 'gpio_func' was declared here
>> pinmux.c:99:3: warning: 'start' may be used uninitialized in this
>> function [-Wmaybe-uninitialized]
>> pinmux.c:69:9: note: 'start' was declared here
>> clock.c: In function 'get_pll_clk':
>> clock.c:178:6: warning: 'fout_sel' may be used uninitialized in this
>> function [-Wmaybe-uninitialized]
>> clock.c:101:35: note: 'fout_sel' was declared here
>> pinmux.c: In function 'exynos_pinmux_config':
>> pinmux.c:100:20: warning: 'gpio_func' may be used uninitialized in
>> this function [-Wmaybe-uninitialized]
>> pinmux.c:69:16: note: 'gpio_func' was declared here
>> pinmux.c:99:3: warning: 'start' may be used uninitialized in this
>> function [-Wmaybe-uninitialized]
>> pinmux.c:69:9: note: 'start' was declared here
>>
>>
> -- Sorry for inconvenience.. will correct them
>>> ---
>>> changes in V2:
>>>         - Incorporated comments from Simon Glass which are removed extra
>>>           braces around (readl(&clk->div_top1)) >> 24 and gave a tab space for
>>>           return statement.
>>> Changes in V3:
>>>         - None
>>> Changes in V4:
>>>         - None
>>> Changes in V5:
>>>         - None.
>>>  arch/arm/cpu/armv7/exynos/clock.c      |   33 ++++++++++++++++++++++++++++++++
>>>  arch/arm/include/asm/arch-exynos/clk.h |    1 +
>>>  2 files changed, 34 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/arch/arm/cpu/armv7/exynos/clock.c b/arch/arm/cpu/armv7/exynos/clock.c
>>> index fc0ed5e..83ee25e 100644
>>> --- a/arch/arm/cpu/armv7/exynos/clock.c
>>> +++ b/arch/arm/cpu/armv7/exynos/clock.c
>>> @@ -602,6 +602,29 @@ void exynos4_set_mipi_clk(void)
>>>         writel(cfg, &clk->div_lcd0);
>>>  }
>>>
>>> +/*
>>> + * I2C
>>> + *
>>> + * exynos5: obtaining the I2C clock
>>> + */
>>> +static unsigned long exynos5_get_i2c_clk(void)
>>> +{
>>> +       struct exynos5_clock *clk =
>>> +               (struct exynos5_clock *)samsung_get_base_clock();
>>> +       unsigned long aclk_66, aclk_66_pre, sclk;
>>> +       unsigned int ratio;
>>> +
>>> +       sclk = get_pll_clk(MPLL);
>>> +
>>> +       ratio = (readl(&clk->div_top1)) >> 24;
>>> +       ratio &= (0x7);
>>
>> Don't really need the ()
> -- ok.
>>
>>> +       aclk_66_pre = sclk/(ratio+1);
>>
>> spaces around operators, and below
> -- will correct this.
>>
>>> +       ratio = readl(&clk->div_top0);
>>> +       ratio &= (0x7);
>>> +       aclk_66 = aclk_66_pre/(ratio+1);
>>> +       return aclk_66;
>>> +}
>>> +
>>>  unsigned long get_pll_clk(int pllreg)
>>>  {
>>>         if (cpu_is_exynos5())
>>> @@ -618,6 +641,16 @@ unsigned long get_arm_clk(void)
>>>                 return exynos4_get_arm_clk();
>>>  }
>>>
>>> +unsigned long get_i2c_clk(void)
>>> +{
>>> +       if (cpu_is_exynos5()) {
>>> +               return exynos5_get_i2c_clk();
>>> +       } else {
>>> +               debug("I2C clock is not set for this CPU\n");
>>> +               return 0;
>>> +       }
>>> +}
>>> +
>>>  unsigned long get_pwm_clk(void)
>>>  {
>>>         if (cpu_is_exynos5())
>>> diff --git a/arch/arm/include/asm/arch-exynos/clk.h b/arch/arm/include/asm/arch-exynos/clk.h
>>> index e99339a..5529025 100644
>>> --- a/arch/arm/include/asm/arch-exynos/clk.h
>>> +++ b/arch/arm/include/asm/arch-exynos/clk.h
>>> @@ -31,6 +31,7 @@
>>>
>>>  unsigned long get_pll_clk(int pllreg);
>>>  unsigned long get_arm_clk(void);
>>> +unsigned long get_i2c_clk(void);
>>>  unsigned long get_pwm_clk(void);
>>>  unsigned long get_uart_clk(int dev_index);
>>>  void set_mmc_clk(int dev_index, unsigned int div);
>>> --
>>> 1.7.4.4
>>>
>>
>> Regards,
>> Simon
>> _______________________________________________
>> U-Boot mailing list
>> U-Boot@lists.denx.de
>> http://lists.denx.de/mailman/listinfo/u-boot
Simon Glass July 19, 2012, 8:20 p.m. UTC | #4
Hi,

On Thu, Jul 19, 2012 at 8:20 AM, Rajeshwari Birje
<rajeshwari.birje@gmail.com> wrote:
> Hi Simon Glass,
>
> The warning messages are fixed in following patch:
> "[PATCH] ARM: EXYNOS: fixed compiler warning message"
> They are applied to u-boot today by Minkyu Kang.

OK great, thank you.

Regards,
Simon

>
> Thanks and Regards,
> Rajeshwari Shinde.
>
> On Thu, Jul 19, 2012 at 11:31 AM, Rajeshwari Birje
> <rajeshwari.birje@gmail.com> wrote:
>> Hi Simon Glass,
>>
>> Thank you for comments.
>>
>> On Wed, Jul 18, 2012 at 10:46 PM, Simon Glass <sjg@chromium.org> wrote:
>>> Hi,
>>>
>>> On Thu, Jul 5, 2012 at 12:59 PM, Rajeshwari Shinde
>>> <rajeshwari.s@samsung.com> wrote:
>>>> This adds i2c clock information for EXYNOS5.
>>>>
>>>> Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com>
>>>> Signed-off-by: Doug Anderson <dianders@chromium.org>
>>>> Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com>
>>>> Acked-by: Simon Glass <sjg@chromium.org>
>>>
>>> Sorry for late comments. Please see below for some nits.
>>>
>>> Also I get these warnings with the samsung/master branch at present:
>>>
>>> clock.c: In function 'get_pll_clk':
>>> clock.c:178:6: warning: 'fout_sel' may be used uninitialized in this
>>> function [-Wmaybe-uninitialized]
>>> clock.c:101:35: note: 'fout_sel' was declared here
>>> pinmux.c: In function 'exynos_pinmux_config':
>>> pinmux.c:100:20: warning: 'gpio_func' may be used uninitialized in
>>> this function [-Wmaybe-uninitialized]
>>> pinmux.c:69:16: note: 'gpio_func' was declared here
>>> pinmux.c:99:3: warning: 'start' may be used uninitialized in this
>>> function [-Wmaybe-uninitialized]
>>> pinmux.c:69:9: note: 'start' was declared here
>>> clock.c: In function 'get_pll_clk':
>>> clock.c:178:6: warning: 'fout_sel' may be used uninitialized in this
>>> function [-Wmaybe-uninitialized]
>>> clock.c:101:35: note: 'fout_sel' was declared here
>>> pinmux.c: In function 'exynos_pinmux_config':
>>> pinmux.c:100:20: warning: 'gpio_func' may be used uninitialized in
>>> this function [-Wmaybe-uninitialized]
>>> pinmux.c:69:16: note: 'gpio_func' was declared here
>>> pinmux.c:99:3: warning: 'start' may be used uninitialized in this
>>> function [-Wmaybe-uninitialized]
>>> pinmux.c:69:9: note: 'start' was declared here
>>>
>>>
>> -- Sorry for inconvenience.. will correct them
>>>> ---
>>>> changes in V2:
>>>>         - Incorporated comments from Simon Glass which are removed extra
>>>>           braces around (readl(&clk->div_top1)) >> 24 and gave a tab space for
>>>>           return statement.
>>>> Changes in V3:
>>>>         - None
>>>> Changes in V4:
>>>>         - None
>>>> Changes in V5:
>>>>         - None.
>>>>  arch/arm/cpu/armv7/exynos/clock.c      |   33 ++++++++++++++++++++++++++++++++
>>>>  arch/arm/include/asm/arch-exynos/clk.h |    1 +
>>>>  2 files changed, 34 insertions(+), 0 deletions(-)
>>>>
>>>> diff --git a/arch/arm/cpu/armv7/exynos/clock.c b/arch/arm/cpu/armv7/exynos/clock.c
>>>> index fc0ed5e..83ee25e 100644
>>>> --- a/arch/arm/cpu/armv7/exynos/clock.c
>>>> +++ b/arch/arm/cpu/armv7/exynos/clock.c
>>>> @@ -602,6 +602,29 @@ void exynos4_set_mipi_clk(void)
>>>>         writel(cfg, &clk->div_lcd0);
>>>>  }
>>>>
>>>> +/*
>>>> + * I2C
>>>> + *
>>>> + * exynos5: obtaining the I2C clock
>>>> + */
>>>> +static unsigned long exynos5_get_i2c_clk(void)
>>>> +{
>>>> +       struct exynos5_clock *clk =
>>>> +               (struct exynos5_clock *)samsung_get_base_clock();
>>>> +       unsigned long aclk_66, aclk_66_pre, sclk;
>>>> +       unsigned int ratio;
>>>> +
>>>> +       sclk = get_pll_clk(MPLL);
>>>> +
>>>> +       ratio = (readl(&clk->div_top1)) >> 24;
>>>> +       ratio &= (0x7);
>>>
>>> Don't really need the ()
>> -- ok.
>>>
>>>> +       aclk_66_pre = sclk/(ratio+1);
>>>
>>> spaces around operators, and below
>> -- will correct this.
>>>
>>>> +       ratio = readl(&clk->div_top0);
>>>> +       ratio &= (0x7);
>>>> +       aclk_66 = aclk_66_pre/(ratio+1);
>>>> +       return aclk_66;
>>>> +}
>>>> +
>>>>  unsigned long get_pll_clk(int pllreg)
>>>>  {
>>>>         if (cpu_is_exynos5())
>>>> @@ -618,6 +641,16 @@ unsigned long get_arm_clk(void)
>>>>                 return exynos4_get_arm_clk();
>>>>  }
>>>>
>>>> +unsigned long get_i2c_clk(void)
>>>> +{
>>>> +       if (cpu_is_exynos5()) {
>>>> +               return exynos5_get_i2c_clk();
>>>> +       } else {
>>>> +               debug("I2C clock is not set for this CPU\n");
>>>> +               return 0;
>>>> +       }
>>>> +}
>>>> +
>>>>  unsigned long get_pwm_clk(void)
>>>>  {
>>>>         if (cpu_is_exynos5())
>>>> diff --git a/arch/arm/include/asm/arch-exynos/clk.h b/arch/arm/include/asm/arch-exynos/clk.h
>>>> index e99339a..5529025 100644
>>>> --- a/arch/arm/include/asm/arch-exynos/clk.h
>>>> +++ b/arch/arm/include/asm/arch-exynos/clk.h
>>>> @@ -31,6 +31,7 @@
>>>>
>>>>  unsigned long get_pll_clk(int pllreg);
>>>>  unsigned long get_arm_clk(void);
>>>> +unsigned long get_i2c_clk(void);
>>>>  unsigned long get_pwm_clk(void);
>>>>  unsigned long get_uart_clk(int dev_index);
>>>>  void set_mmc_clk(int dev_index, unsigned int div);
>>>> --
>>>> 1.7.4.4
>>>>
>>>
>>> Regards,
>>> Simon
>>> _______________________________________________
>>> U-Boot mailing list
>>> U-Boot@lists.denx.de
>>> http://lists.denx.de/mailman/listinfo/u-boot
diff mbox

Patch

diff --git a/arch/arm/cpu/armv7/exynos/clock.c b/arch/arm/cpu/armv7/exynos/clock.c
index fc0ed5e..83ee25e 100644
--- a/arch/arm/cpu/armv7/exynos/clock.c
+++ b/arch/arm/cpu/armv7/exynos/clock.c
@@ -602,6 +602,29 @@  void exynos4_set_mipi_clk(void)
 	writel(cfg, &clk->div_lcd0);
 }
 
+/*
+ * I2C
+ *
+ * exynos5: obtaining the I2C clock
+ */
+static unsigned long exynos5_get_i2c_clk(void)
+{
+	struct exynos5_clock *clk =
+		(struct exynos5_clock *)samsung_get_base_clock();
+	unsigned long aclk_66, aclk_66_pre, sclk;
+	unsigned int ratio;
+
+	sclk = get_pll_clk(MPLL);
+
+	ratio = (readl(&clk->div_top1)) >> 24;
+	ratio &= (0x7);
+	aclk_66_pre = sclk/(ratio+1);
+	ratio = readl(&clk->div_top0);
+	ratio &= (0x7);
+	aclk_66 = aclk_66_pre/(ratio+1);
+	return aclk_66;
+}
+
 unsigned long get_pll_clk(int pllreg)
 {
 	if (cpu_is_exynos5())
@@ -618,6 +641,16 @@  unsigned long get_arm_clk(void)
 		return exynos4_get_arm_clk();
 }
 
+unsigned long get_i2c_clk(void)
+{
+	if (cpu_is_exynos5()) {
+		return exynos5_get_i2c_clk();
+	} else {
+		debug("I2C clock is not set for this CPU\n");
+		return 0;
+	}
+}
+
 unsigned long get_pwm_clk(void)
 {
 	if (cpu_is_exynos5())
diff --git a/arch/arm/include/asm/arch-exynos/clk.h b/arch/arm/include/asm/arch-exynos/clk.h
index e99339a..5529025 100644
--- a/arch/arm/include/asm/arch-exynos/clk.h
+++ b/arch/arm/include/asm/arch-exynos/clk.h
@@ -31,6 +31,7 @@ 
 
 unsigned long get_pll_clk(int pllreg);
 unsigned long get_arm_clk(void);
+unsigned long get_i2c_clk(void);
 unsigned long get_pwm_clk(void);
 unsigned long get_uart_clk(int dev_index);
 void set_mmc_clk(int dev_index, unsigned int div);