linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pankaj Dubey <pankaj.dubey@samsung.com>
To: Tomasz Figa <tomasz.figa@gmail.com>
Cc: linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, kgene.kim@samsung.com,
	linux@arm.linux.org.uk, t.figa@samsung.com, chow.kim@samsung.com,
	yg1004.jang@samsung.com, vikas.sajjan@samsung.com,
	s.nawrocki@samsung.com, b.zolnierkie@samsung.com
Subject: Re: [PATCH v2 06/10] ARM: EXYNOS: Add support for mapping PMU base address via DT
Date: Sun, 27 Apr 2014 16:29:42 +0900	[thread overview]
Message-ID: <535CB1E6.8070500@samsung.com> (raw)
In-Reply-To: <535AD70F.20608@gmail.com>

Hi Tomasz,

Thanks for review.

On 04/26/2014 06:43 AM, Tomasz Figa wrote:
> Hi,
>
> On 25.04.2014 14:32, Pankaj Dubey wrote:
>> From: Young-Gun Jang <yg1004.jang@samsung.com>
>>
>> Add support for mapping Samsung Power Management Unit (PMU) base address
>> from device tree. Code will use existing samsung pmu binding information.
>> This patch also adds two helper functions as "get_exynos_pmuregmap" and
>> "get_exynos_pmuaddr".
>> "get_exynos_pmuregmap" returns a regmap based PMU register handle where as
>> "get_exynos_pmuaddr" returns ioremap virtual address.
>>
>> Signed-off-by: Young-Gun Jang <yg1004.jang@samsung.com>
>> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
>> ---
>>   arch/arm/mach-exynos/Kconfig  |    2 ++
>>   arch/arm/mach-exynos/common.h |    3 ++
>>   arch/arm/mach-exynos/exynos.c |   78 +++++++++++++++++++++++++++++++++++++++++
>>   3 files changed, 83 insertions(+)
>>
>> diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig
>> index fc8bf18..2f60c90 100644
>> --- a/arch/arm/mach-exynos/Kconfig
>> +++ b/arch/arm/mach-exynos/Kconfig
>> @@ -26,6 +26,7 @@ config ARCH_EXYNOS4
>>       select PINCTRL
>>       select PM_GENERIC_DOMAINS if PM_RUNTIME
>>       select S5P_DEV_MFC
>> +    select MFD_SYSCON
>>       help
>>         Samsung EXYNOS4 SoCs based systems
>>
>> @@ -36,6 +37,7 @@ config ARCH_EXYNOS5
>>       select HAVE_ARM_SCU if SMP
>>       select HAVE_SMP
>>       select PINCTRL
>> +    select MFD_SYSCON
>>       help
>>         Samsung EXYNOS5 (Cortex-A15) SoC based systems
>>
>> diff --git a/arch/arm/mach-exynos/common.h b/arch/arm/mach-exynos/common.h
>> index 31c5964..ecfd0fc 100644
>> --- a/arch/arm/mach-exynos/common.h
>> +++ b/arch/arm/mach-exynos/common.h
>> @@ -57,4 +57,7 @@ struct exynos_pmu_conf {
>>
>>   extern void exynos_sys_powerdown_conf(enum sys_powerdown mode);
>>
>> +extern struct regmap *get_exynos_pmuregmap(void);
>> +extern void __iomem *get_exynos_pmuaddr(void);
>
> Do you really need these functions? Couldn't all the drivers using PMU simply 
> call syscon_regmap_lookup_by_phandle() or of_iomap() directly?

Well, currently "get_exynos_pmuregmap" is used in three location under
mach-exynos as "exynos.c", "pm.c" and "hotplug.c" so just to avoid duplicate code
in all these files I added "get_exynos_pmuregmap" as helper function in "exynos.c".
So in my opinion it should be fine. What do you say?

Regarding "get_exynos_pmuaddr", only user of this function is "platsmp.c" so I can
move this function in platsmp.c and remove this helper. This will also solve the 
other
issue of early mapping as you raised below.

>
>> +
>>   #endif /* __ARCH_ARM_MACH_EXYNOS_COMMON_H */
>> diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c
>> index d6f405f..68f60e1 100644
>> --- a/arch/arm/mach-exynos/exynos.c
>> +++ b/arch/arm/mach-exynos/exynos.c
>> @@ -19,6 +19,7 @@
>>   #include <linux/of_platform.h>
>>   #include <linux/platform_device.h>
>>   #include <linux/pm_domain.h>
>> +#include <linux/mfd/syscon.h>
>>
>>   #include <asm/cacheflush.h>
>>   #include <asm/hardware/cache-l2x0.h>
>> @@ -36,6 +37,9 @@
>>   #define L2_AUX_VAL 0x7C470001
>>   #define L2_AUX_MASK 0xC200ffff
>>
>> +static struct regmap *exynos_pmu_regmap;
>> +static void __iomem *exynos_pmu_base;
>> +
>>   static struct map_desc exynos4_iodesc[] __initdata = {
>>       {
>>           .virtual    = (unsigned long)S3C_VA_SYS,
>> @@ -269,6 +273,46 @@ static int __init exynos_fdt_map_chipid(unsigned long 
>> node, const char *uname,
>>       return 1;
>>   }
>>
>> +static const struct of_device_id exynos_dt_pmu_match[] = {
>> +    { .compatible = "samsung,exynos4210-pmu" },
>> +    { .compatible = "samsung,exynos4212-pmu" },
>> +    { .compatible = "samsung,exynos4412-pmu" },
>> +    { .compatible = "samsung,exynos5250-pmu" },
>> +    {},
>> +};
>> +
>> +static int __init exynos_fdt_map_pmu(unsigned long node,
>> +        const char *uname, int depth, void *data)
>> +{
>> +    struct map_desc iodesc;
>> +    __be32 *reg;
>> +    unsigned long len;
>> +    phys_addr_t phys_addr;
>> +    const struct of_device_id *matches = exynos_dt_pmu_match;
>> +
>> +    for (; matches->compatible[0]; matches++) {
>> +        if (!of_flat_dt_is_compatible(node, matches->compatible))
>> +            continue;
>> +        reg = of_get_flat_dt_prop(node, "reg", &len);
>> +        if (reg == NULL || len != (sizeof(unsigned long) * 2))
>> +            return 0;
>> +
>> +        phys_addr = be32_to_cpu(reg[0]);
>> +        iodesc.pfn = __phys_to_pfn(phys_addr);
>> +        iodesc.length = be32_to_cpu(reg[1]) - 1;
>> +        iodesc.virtual = (unsigned long)S5P_VA_PMU;
>> +        iodesc.type = MT_DEVICE;
>> +        iotable_init(&iodesc, 1);
>> +
>> +        exynos_pmu_base = ioremap(phys_addr, be32_to_cpu(reg[1]));
>> +        if (WARN_ON(!exynos_pmu_base))
>> +            return -EFAULT;
>> +        return 1;
>> +    }
>> +
>> +    return 0;
>> +}
>
> Is such early mapping really needed? Couldn't the code using PMU be deferred 
> to the stage that memory management is available and then of_iomap() used 
> directly?

OK, not really required, If I move mapping of PMU base address to platsmp.c.
As "exynos_pmu_base" is only required in platsmp.c during "exynos_smp_prepare_cpus"
function call, I can move mapping of PMU address in platsmp.c itself and there I 
can use of_iomap.

>
>> +
>>   /*
>>    * exynos_map_io
>>    *
>> @@ -302,6 +346,7 @@ static void __init exynos_init_io(void)
>>       debug_ll_io_init();
>>
>>       of_scan_flat_dt(exynos_fdt_map_chipid, NULL);
>> +    of_scan_flat_dt(exynos_fdt_map_pmu, NULL);
>>
>>       /* detect cpu id and rev. */
>>       s5p_init_cpu(S5P_VA_CHIPID);
>> @@ -336,6 +381,38 @@ static int __init exynos4_l2x0_cache_init(void)
>>   }
>>   early_initcall(exynos4_l2x0_cache_init);
>>
>> +
>> +inline struct regmap *get_exynos_pmuregmap()
>> +{
>> +    return exynos_pmu_regmap;
>> +}
>> +
>> +inline void __iomem *get_exynos_pmuaddr()
>> +{
>> +    return exynos_pmu_base;
>> +}
>
> Hmm, non-static inline inside a C file? Probably should be either static 
> inline or non-static non-inline. (Assuming that both are really needed, as I 
> pointed in the comments above.)

OK, will remove "get_exynos_pmuaddr" and make "get_exynos_pmuregmap" as 
non-static non-inline.

>
>> +
>> +
>> +void __init exynos_map_pmu(void)
>> +{
>> +    struct device_node *np = NULL;
>> +
>> +    early_syscon_init();
>> +
>> +    np = of_find_matching_node(NULL, exynos_dt_pmu_match);
>> +
>> +    if (!np) {
>> +        pr_err("Failed to find PMU node\n");
>> +        return;
>> +    } else {
>> +        exynos_pmu_regmap = syscon_early_regmap_lookup_by_phandle(np,
>> +                "samsung,syscon-phandle");
>
> Do you need this regmap really here? I believe it should be the code using PMU 
> registers which calls this function directly to retrieve a handle to the syscon.
>

Yes, as "exynos_restart" is accessing one PMU register. So even though all callers
(pm.c and hotplug.c) directly retrieve a regmap handle to PMU, we need regmap handle
in this file also. So as I mentioned above just to avoid duplicate code in all 
files we can
retrieve regmap handle in "exynos.c" and using helper function other files can 
use it.

> Best regards,
> Tomasz
>


-- 
Best Regards,
Pankaj Dubey


  reply	other threads:[~2014-04-27  7:11 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-02  7:50 [PATCH 0/7] ARM: Exynos: PMU cleanup and refactoring for using DT Pankaj Dubey
2014-04-02  7:50 ` [PATCH 01/10] ARM: EXYNOS: Cleanup "mach-exynos/common.h" file Pankaj Dubey
2014-04-08 15:59   ` Tomasz Figa
2014-04-10  4:35     ` Pankaj Dubey
2014-04-02  7:50 ` [PATCH 02/10] ARM: EXYNOS: Correct file path in comment message Pankaj Dubey
2014-04-02 12:01   ` Michal Simek
2014-04-03  1:40     ` Pankaj Dubey
2014-04-03  2:12       ` Kukjin Kim
2014-04-02  7:50 ` [PATCH 03/10] ARM: EXYNOS: Move SYSREG definition into sys-reg specific file Pankaj Dubey
2014-04-02 11:27   ` Sylwester Nawrocki
2014-04-11  6:07     ` Pankaj Dubey
2014-04-02  7:50 ` [PATCH 04/10] ARM: EXYNOS: Remove regs-pmu.h file dependency from pm_domain Pankaj Dubey
2014-04-02  7:50 ` [PATCH 05/10] ARM: EXYNOS: Move "regs-pmu" header inclusion in common.h Pankaj Dubey
2014-04-08 16:09   ` Tomasz Figa
2014-04-10  4:58     ` Pankaj Dubey
2014-04-02  7:50 ` [PATCH 06/10] ARM: EXYNOS: Add support for mapping PMU base address via DT Pankaj Dubey
2014-04-02 11:48   ` Sylwester Nawrocki
2014-04-02 12:15     ` Michal Simek
2014-04-03  9:07       ` Sylwester Nawrocki
2014-04-05 10:58         ` Pankaj Dubey
2014-04-07  6:02           ` Michal Simek
2014-04-05 10:53     ` Pankaj Dubey
2014-04-23 13:02   ` Vikas Sajjan
2014-04-24  2:45     ` Pankaj Dubey
2014-04-02  7:50 ` [PATCH 07/10] ARM: EXYNOS: Refactored code for PMU register mapping " Pankaj Dubey
2014-04-25 12:32 ` [PATCH v2 00/10] ARM: Exynos: PMU cleanup and refactoring for using DT Pankaj Dubey
2014-04-25 12:32   ` [PATCH v2 01/10] ARM: EXYNOS: Make exynos machine_ops as static Pankaj Dubey
2014-04-25 21:05     ` Tomasz Figa
2014-04-26  4:42       ` Pankaj Dubey
2014-04-25 12:32   ` [PATCH v2 02/10] ARM: EXYNOS: Cleanup "mach-exynos/common.h" file Pankaj Dubey
2014-04-25 21:06     ` Tomasz Figa
2014-04-25 12:32   ` [PATCH v2 03/10] ARM: EXYNOS: Move SYSREG definition into sys-reg specific file Pankaj Dubey
2014-04-25 21:08     ` Tomasz Figa
2014-04-25 12:32   ` [PATCH v2 04/10] ARM: EXYNOS: Remove file path from comment section Pankaj Dubey
2014-04-25 21:14     ` Tomasz Figa
2014-04-25 12:32   ` [PATCH v2 05/10] ARM: EXYNOS: Remove regs-pmu.h header dependency from pm_domain Pankaj Dubey
2014-04-25 21:19     ` Tomasz Figa
2014-04-26  3:39       ` Pankaj Dubey
2014-04-25 12:32   ` [PATCH v2 06/10] ARM: EXYNOS: Add support for mapping PMU base address via DT Pankaj Dubey
2014-04-25 21:43     ` Tomasz Figa
2014-04-27  7:29       ` Pankaj Dubey [this message]
2014-04-25 12:32   ` [PATCH v2 07/10] ARM: EXYNOS: Remove "linux/bug.h" from pmu.c Pankaj Dubey
2014-04-25 21:44     ` Tomasz Figa
2014-04-25 12:32   ` [PATCH v2 08/10] ARM: EXYNOS: Refactored code for using PMU address via DT Pankaj Dubey
2014-04-25 22:19     ` Tomasz Figa
2014-04-26  3:32       ` Pankaj Dubey
2014-04-25 12:32   ` [PATCH v2 09/10] ARM: EXYNOS: Move "mach/map.h" inclusion from regs-pmu.h to platsmp.c Pankaj Dubey
2014-04-25 12:32   ` [PATCH v2 10/10] ARM: EXYNOS: Add device tree based initialization support for PMU Pankaj Dubey
2014-04-25 22:40     ` Tomasz Figa
2014-04-26  4:36       ` Pankaj Dubey
2014-04-25 22:43   ` [PATCH v2 00/10] ARM: Exynos: PMU cleanup and refactoring for using DT Tomasz Figa
2014-04-26  2:07     ` Pankaj Dubey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=535CB1E6.8070500@samsung.com \
    --to=pankaj.dubey@samsung.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=chow.kim@samsung.com \
    --cc=kgene.kim@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=s.nawrocki@samsung.com \
    --cc=t.figa@samsung.com \
    --cc=tomasz.figa@gmail.com \
    --cc=vikas.sajjan@samsung.com \
    --cc=yg1004.jang@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).