Message ID | 1396425058-4012-7-git-send-email-pankaj.dubey@samsung.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 02/04/14 09:50, Pankaj Dubey wrote: > From: Young-Gun Jang <yg1004.jang@samsung.com> > > Add support for mapping Exynos Power Management Unit (PMU) base address > from device tree. Code will use existing samsung pmu binding information. > This patch also adds "get_exynos_pmubase" a helper function to return mapped base > address to various other files under "mach-exynos". > > Signed-off-by: Young-Gun Jang <yg1004.jang@samsung.com> > Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com> > --- > arch/arm/mach-exynos/common.h | 2 ++ > arch/arm/mach-exynos/exynos.c | 44 +++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 46 insertions(+) > [...] > #endif /* __ARCH_ARM_MACH_EXYNOS_COMMON_H */ > diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c > index a5e1349..a5127fb 100644 > --- a/arch/arm/mach-exynos/exynos.c > +++ b/arch/arm/mach-exynos/exynos.c > @@ -35,6 +35,8 @@ > #define L2_AUX_VAL 0x7C470001 > #define L2_AUX_MASK 0xC200ffff > > +static void __iomem *exynos_pmu_base __initdata; > + > static struct map_desc exynos4_iodesc[] __initdata = { > { > .virtual = (unsigned long)S3C_VA_SYS, > @@ -245,6 +247,47 @@ void __init exynos_init_late(void) > exynos_pm_init(); > } > > +static char const *exynos_dt_pmu_match[] __initconst = { > + "samsung,exynos4210-pmu", > + "samsung,exynos4212-pmu", > + "samsung,exynos4412-pmu", > + "samsung,exynos5250-pmu", > + NULL > +}; > + > +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; > + > + if (of_flat_dt_match(node, exynos_dt_pmu_match)) { > + phys_addr_t phys_addr; > + 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); Are you sure...you need this in addition to ioremap() below ? Can't you just use the Linux syscon API ? There were some patches posted for syscon to make it available in earlier system initialization stage: https://lkml.org/lkml/2014/2/19/218 > + exynos_pmu_base = ioremap(phys_addr, be32_to_cpu(reg[1])); > + if (WARN_ON(!exynos_pmu_base)) > + return -EFAULT; > + } > + > + return 0; > +} -- Thanks, Sylwester
On 04/02/2014 01:48 PM, Sylwester Nawrocki wrote: > On 02/04/14 09:50, Pankaj Dubey wrote: >> From: Young-Gun Jang <yg1004.jang@samsung.com> >> >> Add support for mapping Exynos Power Management Unit (PMU) base address >> from device tree. Code will use existing samsung pmu binding information. >> This patch also adds "get_exynos_pmubase" a helper function to return mapped base >> address to various other files under "mach-exynos". >> >> Signed-off-by: Young-Gun Jang <yg1004.jang@samsung.com> >> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com> >> --- >> arch/arm/mach-exynos/common.h | 2 ++ >> arch/arm/mach-exynos/exynos.c | 44 +++++++++++++++++++++++++++++++++++++++++ >> 2 files changed, 46 insertions(+) >> > [...] >> #endif /* __ARCH_ARM_MACH_EXYNOS_COMMON_H */ >> diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c >> index a5e1349..a5127fb 100644 >> --- a/arch/arm/mach-exynos/exynos.c >> +++ b/arch/arm/mach-exynos/exynos.c >> @@ -35,6 +35,8 @@ >> #define L2_AUX_VAL 0x7C470001 >> #define L2_AUX_MASK 0xC200ffff >> >> +static void __iomem *exynos_pmu_base __initdata; >> + >> static struct map_desc exynos4_iodesc[] __initdata = { >> { >> .virtual = (unsigned long)S3C_VA_SYS, >> @@ -245,6 +247,47 @@ void __init exynos_init_late(void) >> exynos_pm_init(); >> } >> >> +static char const *exynos_dt_pmu_match[] __initconst = { >> + "samsung,exynos4210-pmu", >> + "samsung,exynos4212-pmu", >> + "samsung,exynos4412-pmu", >> + "samsung,exynos5250-pmu", >> + NULL >> +}; >> + >> +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; >> + >> + if (of_flat_dt_match(node, exynos_dt_pmu_match)) { >> + phys_addr_t phys_addr; >> + 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); > > Are you sure...you need this in addition to ioremap() below ? > Can't you just use the Linux syscon API ? > There were some patches posted for syscon to make it available in earlier > system initialization stage: https://lkml.org/lkml/2014/2/19/218 I haven't finished this yet. I have to look at it again. Thanks, Michal
On 02/04/14 14:15, Michal Simek wrote: >> There were some patches posted for syscon to make it available in earlier >> system initialization stage: https://lkml.org/lkml/2014/2/19/218 > > I haven't finished this yet. I have to look at it again. Thanks for the information, I assume this would be also useful on the Exynos SoC series, so I'd be happy to see continuation of those works. -- Thanks, Sylwester
On 04/02/2014 08:48 PM, Sylwester Nawrocki wrote: > On 02/04/14 09:50, Pankaj Dubey wrote: >> From: Young-Gun Jang <yg1004.jang@samsung.com> >> >> Add support for mapping Exynos Power Management Unit (PMU) base address >> from device tree. Code will use existing samsung pmu binding information. >> This patch also adds "get_exynos_pmubase" a helper function to return mapped base >> address to various other files under "mach-exynos". >> >> Signed-off-by: Young-Gun Jang <yg1004.jang@samsung.com> >> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com> >> --- >> arch/arm/mach-exynos/common.h | 2 ++ >> arch/arm/mach-exynos/exynos.c | 44 +++++++++++++++++++++++++++++++++++++++++ >> 2 files changed, 46 insertions(+) >> > [...] >> #endif /* __ARCH_ARM_MACH_EXYNOS_COMMON_H */ >> diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c >> index a5e1349..a5127fb 100644 >> --- a/arch/arm/mach-exynos/exynos.c >> +++ b/arch/arm/mach-exynos/exynos.c >> @@ -35,6 +35,8 @@ >> #define L2_AUX_VAL 0x7C470001 >> #define L2_AUX_MASK 0xC200ffff >> >> +static void __iomem *exynos_pmu_base __initdata; >> + >> static struct map_desc exynos4_iodesc[] __initdata = { >> { >> .virtual = (unsigned long)S3C_VA_SYS, >> @@ -245,6 +247,47 @@ void __init exynos_init_late(void) >> exynos_pm_init(); >> } >> >> +static char const *exynos_dt_pmu_match[] __initconst = { >> + "samsung,exynos4210-pmu", >> + "samsung,exynos4212-pmu", >> + "samsung,exynos4412-pmu", >> + "samsung,exynos5250-pmu", >> + NULL >> +}; >> + >> +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; >> + >> + if (of_flat_dt_match(node, exynos_dt_pmu_match)) { >> + phys_addr_t phys_addr; >> + 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); > Are you sure...you need this in addition to ioremap() below ? > Can't you just use the Linux syscon API ? > There were some patches posted for syscon to make it available in earlier > system initialization stage: https://lkml.org/lkml/2014/2/19/218 Thanks for review and suggestion. We need ioremap() in addition to iotable_init to get virtual address, which will be used by other files also for read/write PMU registers. Regarding syscon early initialization, since I was not aware of any such patch earlier I have not used it. But after you suggested I tried it and modified this implementation to use syscon API and regmap API and it's working fine. I will wait for review of other patches in this series and status of above mentioned syscon API based on that I will update this in next revision. >> + exynos_pmu_base = ioremap(phys_addr, be32_to_cpu(reg[1])); >> + if (WARN_ON(!exynos_pmu_base)) >> + return -EFAULT; >> + } >> + >> + return 0; >> +} > -- > Thanks, > Sylwester >
On 04/03/2014 06:07 PM, Sylwester Nawrocki wrote: > On 02/04/14 14:15, Michal Simek wrote: >>> There were some patches posted for syscon to make it available in earlier >>> system initialization stage: https://lkml.org/lkml/2014/2/19/218 >> I haven't finished this yet. I have to look at it again. > Thanks for the information, I assume this would be also useful > on the Exynos SoC series, so I'd be happy to see continuation > of those works. It is useful for Exynos SoC series and I have modified this patch series to use early syscon initialization API and I can see it's working. I have some observation for early initialization of syscon API which I will update in corresponding message thread. > -- > Thanks, > Sylwester >
On 04/05/2014 12:58 PM, Pankaj Dubey wrote: > On 04/03/2014 06:07 PM, Sylwester Nawrocki wrote: >> On 02/04/14 14:15, Michal Simek wrote: >>>> There were some patches posted for syscon to make it available in earlier >>>> system initialization stage: https://lkml.org/lkml/2014/2/19/218 >>> I haven't finished this yet. I have to look at it again. >> Thanks for the information, I assume this would be also useful >> on the Exynos SoC series, so I'd be happy to see continuation >> of those works. > > It is useful for Exynos SoC series and I have modified this patch series to use early syscon > initialization API and I can see it's working. > I have some observation for early initialization of syscon API which I will > update in corresponding message thread. Great. Please update that thread we should finish this implementation to be useful for everybody. Thanks, Michal
Hi, On Wed, Apr 2, 2014 at 1:20 PM, Pankaj Dubey <pankaj.dubey@samsung.com> wrote: > From: Young-Gun Jang <yg1004.jang@samsung.com> > > Add support for mapping Exynos Power Management Unit (PMU) base address > from device tree. Code will use existing samsung pmu binding information. > This patch also adds "get_exynos_pmubase" a helper function to return mapped base > address to various other files under "mach-exynos". > > Signed-off-by: Young-Gun Jang <yg1004.jang@samsung.com> > Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com> > --- > arch/arm/mach-exynos/common.h | 2 ++ > arch/arm/mach-exynos/exynos.c | 44 +++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 46 insertions(+) > > diff --git a/arch/arm/mach-exynos/common.h b/arch/arm/mach-exynos/common.h > index ff28334..9a55cf6 100644 > --- a/arch/arm/mach-exynos/common.h > +++ b/arch/arm/mach-exynos/common.h > @@ -61,4 +61,6 @@ struct exynos_pmu_conf { > > extern void exynos_sys_powerdown_conf(enum sys_powerdown mode); > > +extern void __iomem *get_exynos_pmubase(void); > + > #endif /* __ARCH_ARM_MACH_EXYNOS_COMMON_H */ > diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c > index a5e1349..a5127fb 100644 > --- a/arch/arm/mach-exynos/exynos.c > +++ b/arch/arm/mach-exynos/exynos.c > @@ -35,6 +35,8 @@ > #define L2_AUX_VAL 0x7C470001 > #define L2_AUX_MASK 0xC200ffff > > +static void __iomem *exynos_pmu_base __initdata; Are you sure you want to keep exynos_pmu_base in .init section. I am seeing a crash in platform_do_lowpower() I think you should remove __initdata. > + > static struct map_desc exynos4_iodesc[] __initdata = { > { > .virtual = (unsigned long)S3C_VA_SYS, > @@ -245,6 +247,47 @@ void __init exynos_init_late(void) > exynos_pm_init(); > } > > +static char const *exynos_dt_pmu_match[] __initconst = { > + "samsung,exynos4210-pmu", > + "samsung,exynos4212-pmu", > + "samsung,exynos4412-pmu", > + "samsung,exynos5250-pmu", > + NULL > +}; > + > +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; > + > + if (of_flat_dt_match(node, exynos_dt_pmu_match)) { > + phys_addr_t phys_addr; > + 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 0; > +} > + > +inline void __iomem *get_exynos_pmubase() > +{ > + return exynos_pmu_base; > +} > + > static int __init exynos_fdt_map_chipid(unsigned long node, const char *uname, > int depth, void *data) > { > @@ -301,6 +344,7 @@ 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); > -- > 1.7.10.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/
Hi Vikas, On 04/23/2014 10:02 PM, Vikas Sajjan wrote: > Hi, > > On Wed, Apr 2, 2014 at 1:20 PM, Pankaj Dubey <pankaj.dubey@samsung.com> wrote: >> From: Young-Gun Jang <yg1004.jang@samsung.com> >> >> Add support for mapping Exynos Power Management Unit (PMU) base address >> from device tree. Code will use existing samsung pmu binding information. >> This patch also adds "get_exynos_pmubase" a helper function to return mapped base >> address to various other files under "mach-exynos". >> >> Signed-off-by: Young-Gun Jang <yg1004.jang@samsung.com> >> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com> >> --- >> arch/arm/mach-exynos/common.h | 2 ++ >> arch/arm/mach-exynos/exynos.c | 44 +++++++++++++++++++++++++++++++++++++++++ >> 2 files changed, 46 insertions(+) >> >> diff --git a/arch/arm/mach-exynos/common.h b/arch/arm/mach-exynos/common.h >> index ff28334..9a55cf6 100644 >> --- a/arch/arm/mach-exynos/common.h >> +++ b/arch/arm/mach-exynos/common.h >> @@ -61,4 +61,6 @@ struct exynos_pmu_conf { >> >> extern void exynos_sys_powerdown_conf(enum sys_powerdown mode); >> >> +extern void __iomem *get_exynos_pmubase(void); >> + >> #endif /* __ARCH_ARM_MACH_EXYNOS_COMMON_H */ >> diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c >> index a5e1349..a5127fb 100644 >> --- a/arch/arm/mach-exynos/exynos.c >> +++ b/arch/arm/mach-exynos/exynos.c >> @@ -35,6 +35,8 @@ >> #define L2_AUX_VAL 0x7C470001 >> #define L2_AUX_MASK 0xC200ffff >> >> +static void __iomem *exynos_pmu_base __initdata; > Are you sure you want to keep exynos_pmu_base in .init section. > I am seeing a crash in platform_do_lowpower() > I think you should remove __initdata. Thanks for review and testing. You are right we do not need __initdata here. I will take care of this in V2. >> + >> static struct map_desc exynos4_iodesc[] __initdata = { >> { >> .virtual = (unsigned long)S3C_VA_SYS, >> @@ -245,6 +247,47 @@ void __init exynos_init_late(void) >> exynos_pm_init(); >> } >> >> +static char const *exynos_dt_pmu_match[] __initconst = { >> + "samsung,exynos4210-pmu", >> + "samsung,exynos4212-pmu", >> + "samsung,exynos4412-pmu", >> + "samsung,exynos5250-pmu", >> + NULL >> +}; >> + >> +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; >> + >> + if (of_flat_dt_match(node, exynos_dt_pmu_match)) { >> + phys_addr_t phys_addr; >> + 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 0; >> +} >> + >> +inline void __iomem *get_exynos_pmubase() >> +{ >> + return exynos_pmu_base; >> +} >> + >> static int __init exynos_fdt_map_chipid(unsigned long node, const char *uname, >> int depth, void *data) >> { >> @@ -301,6 +344,7 @@ 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); >> -- >> 1.7.10.4 >> >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html >> Please read the FAQ at http://www.tux.org/lkml/
diff --git a/arch/arm/mach-exynos/common.h b/arch/arm/mach-exynos/common.h index ff28334..9a55cf6 100644 --- a/arch/arm/mach-exynos/common.h +++ b/arch/arm/mach-exynos/common.h @@ -61,4 +61,6 @@ struct exynos_pmu_conf { extern void exynos_sys_powerdown_conf(enum sys_powerdown mode); +extern void __iomem *get_exynos_pmubase(void); + #endif /* __ARCH_ARM_MACH_EXYNOS_COMMON_H */ diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c index a5e1349..a5127fb 100644 --- a/arch/arm/mach-exynos/exynos.c +++ b/arch/arm/mach-exynos/exynos.c @@ -35,6 +35,8 @@ #define L2_AUX_VAL 0x7C470001 #define L2_AUX_MASK 0xC200ffff +static void __iomem *exynos_pmu_base __initdata; + static struct map_desc exynos4_iodesc[] __initdata = { { .virtual = (unsigned long)S3C_VA_SYS, @@ -245,6 +247,47 @@ void __init exynos_init_late(void) exynos_pm_init(); } +static char const *exynos_dt_pmu_match[] __initconst = { + "samsung,exynos4210-pmu", + "samsung,exynos4212-pmu", + "samsung,exynos4412-pmu", + "samsung,exynos5250-pmu", + NULL +}; + +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; + + if (of_flat_dt_match(node, exynos_dt_pmu_match)) { + phys_addr_t phys_addr; + 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 0; +} + +inline void __iomem *get_exynos_pmubase() +{ + return exynos_pmu_base; +} + static int __init exynos_fdt_map_chipid(unsigned long node, const char *uname, int depth, void *data) { @@ -301,6 +344,7 @@ 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);