xen: arm: platforms: Adding reset support for xgene arm64 platform.
PATCH v3 1/1 xen: arm: platforms: Adding reset support for xgene arm64 platform.
This patch adds a reset support for xgene arm64 platform.
V3:
- Retriving reset base address and reset mask from device tree.
- Removed unnecssary header files included earlier. V2:
- Removed unnecssary mdelay in code.
- Adding iounmap of the base address.
V1:
-Initial patch.
--- xen/arch/arm/platforms/xgene-storm.c | 70 ++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)
xen/arch/arm/platforms/xgene-storm.c +70 -0
@@ -20,8 +20,17 @@#include <xen/config.h> #include <asm/platform.h> +#include <xen/vmap.h> +#include <asm/io.h> #include <asm/gic.h> +#define DT_MATCH_RESET \ + DT_MATCH_COMPATIBLE("apm,xgene-reboot") + +/* Variables to save reset address of soc during platform initialization. */ +static u64 reset_addr, reset_size; +static u32 reset_mask; +static uint32_t xgene_storm_quirks (void ) {return PLATFORM_QUIRK_GIC_64K_STRIDE ;
@@ -107,6 +116,65 @@ err:return ret; } +/* +* TODO: Get base address and mask from the device tree +*/ +static void xgene_storm_reset (void ) +{ +void __iomem *addr; + + addr =ioremap_nocache (reset_addr, reset_size); + +if ( !addr ) + { +printk ("Unable to map xgene reset address\n" ); +return ; + } + +/* Write mask 0x1 to base address */ +writel (reset_mask, addr); + +iounmap (addr); +} + +static int xgene_storm_init (void ) +{ +static const struct dt_device_match reset_ids[]__initconst = + { +DT_MATCH_RESET , + {}, + }; +struct dt_device_node *dev; +int res; + + dev =dt_find_matching_node (NULL , reset_ids); +if ( !dev ) + { +printk ("Unable to find a compatible reset node in " +"the device tree" ); +return -ENODEV ; + } + +dt_device_set_used_by (dev,DOMID_XEN ); + +/* Retrieve base address and size */ + res =dt_device_get_address (dev,0 , &reset_addr, &reset_size); +if ( res ) + { +printk ("Unable to retrieve the base address for reset\n" ); +return res; + } + +/* Get reset mask */ + res =dt_property_read_u32 (dev,"mask" , &reset_mask); +if ( !res ) + { +printk ("Unable to retrieve the reset mask\n" ); +return res; + } + +return 0 ; +}static const char *const xgene_storm_dt_compat[]__initconst = {
@@ -116,6 +184,8 @@ static const char * const xgene_storm_dt_compat[] __initconst =PLATFORM_START (xgene_storm,"APM X-GENE STORM" ) .compatible = xgene_storm_dt_compat, + .init = xgene_storm_init, + .reset = xgene_storm_reset, .quirks = xgene_storm_quirks, .specific_mapping = xgene_storm_specific_mapping,
Signature · 1 line
1.7.9.5
Hi,
Quoted 40 lines · Pranavkumar Sawargaonkar
This patch adds a reset support for xgene arm64 platform.
V3:
- Retriving reset base address and reset mask from device tree.
- Removed unnecssary header files included earlier. V2:
- Removed unnecssary mdelay in code.
- Adding iounmap of the base address.
V1:
-Initial patch.Signed-off-by Pranavkumar Sawargaonkar <[email protected]>Signed-off-by Anup Patel <[email protected]>--- xen/arch/arm/platforms/xgene-storm.c | 70 ++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)xen/arch/arm/platforms/xgene-storm.c +9
-0@@ -20,8 +20,17 @@#include <xen/config.h> #include <asm/platform.h> +#include <xen/vmap.h> +#include <asm/io.h> #include <asm/gic.h> +#define DT_MATCH_RESET \ + DT_MATCH_COMPATIBLE("apm,xgene-reboot") + +/* Variables to save reset address of soc during platform initialization. */ +static u64 reset_addr, reset_size; +static u32 reset_mask; +static uint32_t xgene_storm_quirks (void ) {return PLATFORM_QUIRK_GIC_64K_STRIDE ;
xen/arch/arm/platforms/xgene-storm.c err: · line 121
Quoted 6 lines
xen/arch/arm/platforms/xgene-storm.c +3
-0@@ -107,6 +116,65 @@ err:return ret; } +/* +* TODO: Get base address and mask from the device tree +*/
Will resend a patch with removal of this comment.
Quoted 69 lines
xen/arch/arm/platforms/xgene-storm.c +58
-1+static void xgene_storm_reset (void ) +{ +void __iomem *addr; + + addr =ioremap_nocache (reset_addr, reset_size); + +if ( !addr ) + { +printk ("Unable to map xgene reset address\n" ); +return ; + } + +/* Write mask 0x1 to base address */ +writel (reset_mask, addr); + +iounmap (addr); +} + +static int xgene_storm_init (void ) +{ +static const struct dt_device_match reset_ids[]__initconst = + { +DT_MATCH_RESET , + {}, + }; +struct dt_device_node *dev; +int res; + + dev =dt_find_matching_node (NULL , reset_ids); +if ( !dev ) + { +printk ("Unable to find a compatible reset node in " +"the device tree" ); +return -ENODEV ; + } + +dt_device_set_used_by (dev,DOMID_XEN ); + +/* Retrieve base address and size */ + res =dt_device_get_address (dev,0 , &reset_addr, &reset_size); +if ( res ) + { +printk ("Unable to retrieve the base address for reset\n" ); +return res; + } + +/* Get reset mask */ + res =dt_property_read_u32 (dev,"mask" , &reset_mask); +if ( !res ) + { +printk ("Unable to retrieve the reset mask\n" ); +return res; + } + +return 0 ; +}static const char *const xgene_storm_dt_compat[]__initconst = {@@ -116,6 +184,8 @@ static const char * const xgene_storm_dt_compat[] __initconst =PLATFORM_START (xgene_storm,"APM X-GENE STORM" ) .compatible = xgene_storm_dt_compat, + .init = xgene_storm_init, + .reset = xgene_storm_reset, .quirks = xgene_storm_quirks, .specific_mapping = xgene_storm_specific_mapping, --
Quoted 2 lines
1.7.9.5
Thanks,
Pranav
Quoted 22 lines · Pranavkumar Sawargaonkar
This patch adds a reset support for xgene arm64 platform.
V3:
- Retriving reset base address and reset mask from device tree.
- Removed unnecssary header files included earlier. V2:
- Removed unnecssary mdelay in code.
- Adding iounmap of the base address.
V1:
-Initial patch.Signed-off-by Pranavkumar Sawargaonkar <[email protected]>Signed-off-by Anup Patel <[email protected]>--- xen/arch/arm/platforms/xgene-storm.c | 70 ++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)xen/arch/arm/platforms/xgene-storm.c +0
-0
xen/arch/arm/platforms/xgene-storm.c line 28
Quoted 9 lines
xen/arch/arm/platforms/xgene-storm.c +4
-0@@ -20,8 +20,17 @@#include <xen/config.h> #include <asm/platform.h> +#include <xen/vmap.h> +#include <asm/io.h> #include <asm/gic.h> +#define DT_MATCH_RESET \ + DT_MATCH_COMPATIBLE("apm,xgene-reboot")
The gic and timer use a #define here because it is needed in multiple places, for this use case you can just inline it into the array in xgene_storm_init. i.e.:
xen/arch/arm/platforms/xgene-storm.c err: · line 144
Quoted 5 lines
xen/arch/arm/platforms/xgene-storm.c +5
-0+static int xgene_storm_init (void ) +{ +static const struct dt_device_match reset_ids[]__initconst = + { +DT_MATCH_RESET ,
DT_MATCH_COMPATIBLE("apm,xgene-reboot")
is fine IMHO.
xen/arch/arm/platforms/xgene-storm.c err: · line 154
Quoted 10 lines
xen/arch/arm/platforms/xgene-storm.c +10
-0+ {}, + }; +struct dt_device_node *dev; +int res; + + dev =dt_find_matching_node (NULL , reset_ids); +if ( !dev ) + { +printk ("Unable to find a compatible reset node in " +"the device tree" );
Please don't wrap string constants, it makes it hard to grep and I'd rather have a long line (in this case it's not too long either).
Please can you add an xgene: (or whatever is appropriate) prefix too.
Quoted 1 line
+ return
-ENODEV;
I wonder if it is worth returning success here? The system would be mostly functional after all.
(You could apply this logic to the other returns if you wish, although if the node is present then an error in the content could be considered more critical to abort on)
Quoted 9 lines
xen/arch/arm/platforms/xgene-storm.c +9
-0+ } + +dt_device_set_used_by (dev,DOMID_XEN ); + +/* Retrieve base address and size */ + res =dt_device_get_address (dev,0 , &reset_addr, &reset_size); +if ( res ) + { +printk ("Unable to retrieve the base address for reset\n" );
xen/arch/arm/platforms/xgene-storm.c err: · line 174
Quoted 10 lines
xen/arch/arm/platforms/xgene-storm.c +10
-0+return res; + } + +/* Get reset mask */ + res =dt_property_read_u32 (dev,"mask" , &reset_mask); +if ( !res ) + { +printk ("Unable to retrieve the reset mask\n" ); +return res; + }
All looks good, thanks.
Quoted 15 lines
xen/arch/arm/platforms/xgene-storm.c +5
-0+ +return 0 ; +}static const char *const xgene_storm_dt_compat[]__initconst = {@@ -116,6 +184,8 @@ static const char * const xgene_storm_dt_compat[] __initconst =PLATFORM_START (xgene_storm,"APM X-GENE STORM" ) .compatible = xgene_storm_dt_compat, + .init = xgene_storm_init, + .reset = xgene_storm_reset, .quirks = xgene_storm_quirks, .specific_mapping = xgene_storm_specific_mapping,
Hi Ian,
Quoted 45 lines · Ian Campbell
Quoted 22 lines · Pranavkumar Sawargaonkar
This patch adds a reset support for xgene arm64 platform.
V3:
- Retriving reset base address and reset mask from device tree.
- Removed unnecssary header files included earlier. V2:
- Removed unnecssary mdelay in code.
- Adding iounmap of the base address.
V1:
-Initial patch.Signed-off-by Pranavkumar Sawargaonkar <[email protected]>Signed-off-by Anup Patel <[email protected]>--- xen/arch/arm/platforms/xgene-storm.c | 70 ++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)xen/arch/arm/platforms/xgene-storm.c +0
-0xen/arch/arm/platforms/xgene-storm.c line 28
Quoted 9 lines
xen/arch/arm/platforms/xgene-storm.c +4
-0@@ -20,8 +20,17 @@#include <xen/config.h> #include <asm/platform.h> +#include <xen/vmap.h> +#include <asm/io.h> #include <asm/gic.h> +#define DT_MATCH_RESET \ + DT_MATCH_COMPATIBLE("apm,xgene-reboot")The gic and timer use a #define here because it is needed in multiple places, for this use case you can just inline it into the array in
xgene_storm_init. i.e.:xen/arch/arm/platforms/xgene-storm.c err: · line 144
Quoted 5 lines
xen/arch/arm/platforms/xgene-storm.c +5
-0+static int xgene_storm_init (void ) +{ +static const struct dt_device_match reset_ids[]__initconst = + { +DT_MATCH_RESET ,
DT_MATCH_COMPATIBLE("apm,xgene-reboot")
Quoted 1 line
is fine IMHO.
Sure i will fix this,
Quoted 12 lines
xen/arch/arm/platforms/xgene-storm.c err: · line 154
Quoted 11 lines
xen/arch/arm/platforms/xgene-storm.c +10
-0+ {}, + }; +struct dt_device_node *dev; +int res; + + dev =dt_find_matching_node (NULL , reset_ids); +if ( !dev ) + { +printk ("Unable to find a compatible reset node in " +"the device tree" );
Quoted 4 lines
Please don't wrap string constants, it makes it hard to grep and I'd rather have a long line (in this case it's not too long either).
Please can you add an xgene: (or whatever is appropriate) prefix too.
Yes will do it.
Quoted 9 lines
Quoted 2 lines
+ return
-ENODEV;I wonder if it is worth returning success here? The system would be mostly functional after all.
(You could apply this logic to the other returns if you wish, although if the node is present then an error in the content could be considered more critical to abort on)
Yeah actually i also wonder about correct return value since system is mostly functional without this.
I will return a success here.
Quoted 14 lines
Quoted 14 lines
xen/arch/arm/platforms/xgene-storm.c +13
-0+ } + +dt_device_set_used_by (dev,DOMID_XEN ); + +/* Retrieve base address and size */ + res =dt_device_get_address (dev,0 , &reset_addr, &reset_size); +if ( res ) + { +printk ("Unable to retrieve the base address for reset\n" ); +return res; + } + +/* Get reset mask */
Quoted 8 lines
xen/arch/arm/platforms/xgene-storm.c err: · line 174
Quoted 6 lines
xen/arch/arm/platforms/xgene-storm.c +6
-0+ res =dt_property_read_u32 (dev,"mask" , &reset_mask); +if ( !res ) + { +printk ("Unable to retrieve the reset mask\n" ); +return res; + }All looks good, thanks.
Thanks, will send out a new patch today.
Quoted 10 lines
Quoted 10 lines
xen/arch/arm/platforms/xgene-storm.c +3
-0+ +return 0 ; +}static const char *const xgene_storm_dt_compat[]__initconst = {@@ -116,6 +184,8 @@ static const char * const xgene_storm_dt_compat[] __initconst =
Quoted 9 lines
xen/arch/arm/platforms/xgene-storm.c static const char * const xgene_storm_dt_compat[] __initconst = · line 191
Quoted 7 lines
xen/arch/arm/platforms/xgene-storm.c +2
-0PLATFORM_START (xgene_storm,"APM X-GENE STORM" ) .compatible = xgene_storm_dt_compat, + .init = xgene_storm_init, + .reset = xgene_storm_reset, .quirks = xgene_storm_quirks, .specific_mapping = xgene_storm_specific_mapping,
Thanks,
Pranav