xtensa: clean up platform interface
Max Filippov
maintainerPATCH 1/5 xtensa: xt2000: drop empty platform_init
In reply to Max Filippovplatform_init doesn't do anything for xt2000, drop it.
--- arch/xtensa/platforms/xt2000/setup.c | 6 ------ 1 file changed, 6 deletions(-)
arch/xtensa/platforms/xt2000/setup.c +0 -6
@@ -68,12 +68,6 @@ void __init platform_setup(char** cmdline)led_print (0 ,"LINUX " ); } -/* early initialization */ - -void __init platform_init (bp_tag_t *first) -{ -} -/* Heartbeat. Let the LED blink. */ void platform_heartbeat (void )
Signature · 1 line
2.30.2
Max Filippov
maintainercover xtensa: clean up platform interface
Hello,
this series drops platform_* interfaces that lost their meaning or got a different standard implementation and cleans up existing users and default definitions.
Max Filippov (5):
xtensa: xt2000: drop empty platform_init
xtensa: drop platform_heartbeat
xtensa: drop platform_restart
xtensa: drop platform_halt and platform_power_off
xtensa: clean up default platform functions
arch/xtensa/include/asm/platform.h | 20 ------------ arch/xtensa/kernel/platform.c | 29 +++++++++-------- arch/xtensa/kernel/setup.c | 22 ++++++++++--- arch/xtensa/kernel/time.c | 4 --- arch/xtensa/platforms/iss/setup.c | 24 ++++++++------ arch/xtensa/platforms/xt2000/setup.c | 48 ++++++++++++++-------------- arch/xtensa/platforms/xtfpga/setup.c | 34 +++++++++++++------- 7 files changed, 94 insertions(+), 87 deletions(-)
Signature · 1 line
2.30.2
Max Filippov
maintainerPATCH 2/5 xtensa: drop platform_heartbeat
platform_heartbeat is called from the timer interrupt handler, but there may be no periodic timer interrupts on xtensa, so the frequency of platform_heartbeat calls may be unrelated to HZ. Drop the callback and reimplement its only user with a timer.
--- arch/xtensa/include/asm/platform.h | 5 ----- arch/xtensa/kernel/platform.c | 1 - arch/xtensa/kernel/time.c | 4 ---- arch/xtensa/platforms/xt2000/setup.c | 20 +++++++++++--------- 4 files changed, 11 insertions(+), 19 deletions(-)
arch/xtensa/include/asm/platform.h +0 -5
@@ -47,11 +47,6 @@ extern void platform_power_off (void);*/ extern void platform_idle (void ); -/* -* platform_heartbeat is called every HZ -*/ -extern void platform_heartbeat (void ); -/* * platform_calibrate_ccount calibrates cpu clock freq (CONFIG_XTENSA_CALIBRATE) */
arch/xtensa/kernel/platform.c +0 -1
@@ -32,7 +32,6 @@ _F(void, restart, (void), { while(1); }); _F(void, halt, (void), { while(1); }); _F(void, power_off, (void), { while(1); }); _F(void, idle, (void), { __asm__ __volatile__ ("waiti 0" ::: "memory"); }); -_F(void, heartbeat, (void), { });#ifdef CONFIG_XTENSA_CALIBRATE_CCOUNT _F(void, calibrate_ccount, (void),
arch/xtensa/kernel/time.c +0 -4
@@ -121,10 +121,6 @@ static irqreturn_t timer_interrupt(int irq, void *dev_id)set_linux_timer (get_linux_timer ()); evt->event_handler (evt); - -/* Allow platform to do something useful (Wdog). */ -platform_heartbeat (); -return IRQ_HANDLED ; }
arch/xtensa/platforms/xt2000/setup.c +11 -9
@@ -23,6 +23,7 @@#include <linux/platform_device.h> #include <linux/serial.h> #include <linux/serial_8250.h> +#include <linux/timer.h> #include <asm/processor.h> #include <asm/platform.h>
@@ -70,16 +71,17 @@ void __init platform_setup(char** cmdline)/* Heartbeat. Let the LED blink. */ -void platform_heartbeat (void ) +static void xt2000_heartbeat (struct timer_list *unused); + +static DEFINE_TIMER(heartbeat_timer, xt2000_heartbeat); + +static void xt2000_heartbeat (struct timer_list *unused) { -static int i, t; +static int i; -if (--t <0 ) - { - t =59 ; -led_print (7 , i ?"." :" " ); - i ^=1 ; - } +led_print (7 , i ?"." :" " ); + i ^=1 ; +mod_timer (&heartbeat_timer, jiffies +HZ /2 ); }//#define RS_TABLE_SIZE 2
@@ -137,7 +139,7 @@ static int __init xt2000_setup_devinit(void) {platform_device_register (&xt2000_serial8250_device);platform_device_register (&xt2000_sonic_device); - +mod_timer (&heartbeat_timer, jiffies +HZ /2 );return 0 ; }
Signature · 1 line
2.30.2
Max Filippov
maintainerPATCH 3/5 xtensa: drop platform_restart
In reply to Max FilippovInstead of using xtensa-specific platform_restart callback use do_kernel_restart in the machine_restart implementation and reimplement existing platform_restart users with register_restart_handler. Drop platform_restart declaration and default implementation.
--- arch/xtensa/include/asm/platform.h | 5 ----- arch/xtensa/kernel/platform.c | 1 - arch/xtensa/kernel/setup.c | 8 +++++++- arch/xtensa/platforms/iss/setup.c | 12 ++++++++++-- arch/xtensa/platforms/xt2000/setup.c | 11 +++++++++-- arch/xtensa/platforms/xtfpga/setup.c | 20 ++++++++++++++++++-- 6 files changed, 44 insertions(+), 13 deletions(-)
arch/xtensa/include/asm/platform.h +0 -5
@@ -27,11 +27,6 @@ extern void platform_init(bp_tag_t*);*/ extern void platform_setup (char **); -/* -* platform_restart is called to restart the system. -*/ -extern void platform_restart (void ); -/* * platform_halt is called to stop the system and halt. */
arch/xtensa/kernel/platform.c +0 -1
@@ -28,7 +28,6 @@_F (void, init, (bp_tag_t *first), { }); _F(void, setup, (char** cmd), { }); -_F(void, restart, (void), { while(1); }); _F(void, halt, (void), { while(1); }); _F(void, power_off, (void), { while(1); }); _F(void, idle, (void), { __asm__ __volatile__ ("waiti 0" ::: "memory"); });
arch/xtensa/kernel/setup.c +7 -1
@@ -22,6 +22,7 @@#include <linux/screen_info.h> #include <linux/kernel.h> #include <linux/percpu.h> +#include <linux/reboot.h> #include <linux/cpu.h> #include <linux/of.h> #include <linux/of_fdt.h>
@@ -522,7 +523,12 @@ void cpu_reset(void)void machine_restart (char * cmd) { -platform_restart (); +local_irq_disable (); +smp_send_stop (); +do_kernel_restart (cmd); +pr_err ("Reboot failed -- System halted\n" ); +while (1 ) +cpu_relax (); }void machine_halt (void )
arch/xtensa/platforms/iss/setup.c +10 -2
@@ -16,6 +16,7 @@#include <linux/notifier.h> #include <linux/panic_notifier.h> #include <linux/printk.h> +#include <linux/reboot.h> #include <linux/string.h> #include <asm/platform.h>
@@ -36,14 +37,20 @@ void platform_power_off(void)simc_exit (0 ); } -void platform_restart (void ) +static int iss_restart (struct notifier_block *this, +unsigned long event,void *ptr) {/* Flush and reset the mmu, simulate a processor reset, and * jump to the reset vector. */ cpu_reset (); -/* control never gets here */ + +return NOTIFY_DONE ; } +static struct notifier_block iss_restart_block = { + .notifier_call = iss_restart, +}; +static int iss_panic_event (struct notifier_block *this,unsigned long event,void *ptr) {
@@ -82,4 +89,5 @@ void __init platform_setup(char **p_cmdline) }atomic_notifier_chain_register (&panic_notifier_list, &iss_panic_block); +register_restart_handler (&iss_restart_block); }
arch/xtensa/platforms/xt2000/setup.c +9 -2
@@ -56,14 +56,20 @@ void platform_power_off(void)while (1 ); } -void platform_restart (void ) +static int xt2000_restart (struct notifier_block *this, +unsigned long event,void *ptr) {/* Flush and reset the mmu, simulate a processor reset, and * jump to the reset vector. */ cpu_reset (); -/* control never gets here */ + +return NOTIFY_DONE ; } +static struct notifier_block xt2000_restart_block = { + .notifier_call = xt2000_restart, +}; +void __init platform_setup (char ** cmdline) {led_print (0 ,"LINUX " );
@@ -140,6 +146,7 @@ static int __init xt2000_setup_devinit(void)platform_device_register (&xt2000_serial8250_device);platform_device_register (&xt2000_sonic_device);mod_timer (&heartbeat_timer, jiffies +HZ /2 ); +register_restart_handler (&xt2000_restart_block);return 0 ; }
arch/xtensa/platforms/xtfpga/setup.c +18 -2
@@ -49,7 +49,8 @@ void platform_power_off(void)cpu_relax (); } -void platform_restart (void ) +static int xtfpga_restart (struct notifier_block *this, +unsigned long event,void *ptr) {/* Try software reset first. */ WRITE_ONCE (*(u32 *)XTFPGA_SWRST_VADDR ,0xdead );
@@ -58,9 +59,14 @@ void platform_restart(void)* simulate a processor reset, and jump to the reset vector. */ cpu_reset (); -/* control never gets here */ + +return NOTIFY_DONE ; } +static struct notifier_block xtfpga_restart_block = { + .notifier_call = xtfpga_restart, +}; +#ifdef CONFIG_XTENSA_CALIBRATE_CCOUNT void __init platform_calibrate_ccount (void )
@@ -70,6 +76,11 @@ void __init platform_calibrate_ccount(void)#endif +static void __init xtfpga_register_handlers (void ) +{ +register_restart_handler (&xtfpga_restart_block); +} +#ifdef CONFIG_USE_OF static void __init xtfpga_clk_setup (struct device_node *np)
@@ -134,6 +145,9 @@ static int __init machine_setup(void)if ((eth =of_find_compatible_node (eth,NULL ,"opencores,ethoc" )))update_local_mac (eth);of_node_put (eth); + +xtfpga_register_handlers (); +return 0 ; }arch_initcall (machine_setup);
@@ -281,6 +295,8 @@ static int __init xtavnet_init(void)pr_info ("XTFPGA: Ethernet MAC %pM\n" , ethoc_pdata.hwaddr); ethoc_pdata.eth_clkfreq = *(long *)XTFPGA_CLKFRQ_VADDR ; +xtfpga_register_handlers (); +return 0 ; }
Signature · 1 line
2.30.2
Max Filippov
maintainerPATCH 4/5 xtensa: drop platform_halt and platform_power_off
In reply to Max FilippovInstead of using xtensa-specific platform_halt and platform_power_off callbacks use do_kernel_power_off in the machine_halt and machine_power_off and reimplement existing platform_halt and platform_power_off users with register_sys_off_handler.
Drop platform_halt and platform_power_off declarations and default implementations.
--- arch/xtensa/include/asm/platform.h | 10 ---------- arch/xtensa/kernel/platform.c | 2 -- arch/xtensa/kernel/setup.c | 14 ++++++++++---- arch/xtensa/platforms/iss/setup.c | 12 +++++------- arch/xtensa/platforms/xt2000/setup.c | 13 +++++-------- arch/xtensa/platforms/xtfpga/setup.c | 14 +++++--------- 6 files changed, 25 insertions(+), 40 deletions(-)
arch/xtensa/include/asm/platform.h +0 -10
@@ -27,16 +27,6 @@ extern void platform_init(bp_tag_t*);*/ extern void platform_setup (char **); -/* -* platform_halt is called to stop the system and halt. -*/ -extern void platform_halt (void ); - -/* -* platform_power_off is called to stop the system and power it off. -*/ -extern void platform_power_off (void ); -/* * platform_idle is called from the idle function. */
arch/xtensa/kernel/platform.c +0 -2
@@ -28,8 +28,6 @@_F (void, init, (bp_tag_t *first), { }); _F(void, setup, (char** cmd), { }); -_F(void, halt, (void), { while(1); }); -_F(void, power_off, (void), { while(1); }); _F(void, idle, (void), { __asm__ __volatile__ ("waiti 0" ::: "memory"); });#ifdef CONFIG_XTENSA_CALIBRATE_CCOUNT
arch/xtensa/kernel/setup.c +10 -4
@@ -533,14 +533,20 @@ void machine_restart(char * cmd)void machine_halt (void ) { -platform_halt (); -while (1 ); +local_irq_disable (); +smp_send_stop (); +do_kernel_power_off (); +while (1 ) +cpu_relax (); }void machine_power_off (void ) { -platform_power_off (); -while (1 ); +local_irq_disable (); +smp_send_stop (); +do_kernel_power_off (); +while (1 ) +cpu_relax (); }#ifdef CONFIG_PROC_FS
arch/xtensa/platforms/iss/setup.c +5 -7
@@ -25,16 +25,11 @@#include <platform/simcall.h> -void platform_halt (void ) -{ -pr_info (" ** Called platform_halt() **\n" ); -simc_exit (0 ); -} - -void platform_power_off (void ) +static int iss_power_off (struct sys_off_data *unused) {pr_info (" ** Called platform_power_off() **\n" );simc_exit (0 ); +return NOTIFY_DONE ; } static int iss_restart(struct notifier_block *this,
@@ -90,4 +85,7 @@ void __init platform_setup(char **p_cmdline)atomic_notifier_chain_register (&panic_notifier_list, &iss_panic_block);register_restart_handler (&iss_restart_block); +register_sys_off_handler (SYS_OFF_MODE_POWER_OFF , +SYS_OFF_PRIO_PLATFORM , + iss_power_off,NULL ); }
arch/xtensa/platforms/xt2000/setup.c +5 -8
@@ -42,18 +42,12 @@ static void led_print (int f, char *s)break ; } -void platform_halt (void ) -{ -led_print (0 ," HALT " ); -local_irq_disable (); -while (1 ); -} - -void platform_power_off (void ) +static int xt2000_power_off (struct sys_off_data *unused) {led_print (0 ,"POWEROFF" );local_irq_disable ();while (1 ); +return NOTIFY_DONE ; } static int xt2000_restart(struct notifier_block *this,
@@ -147,6 +141,9 @@ static int __init xt2000_setup_devinit(void)platform_device_register (&xt2000_sonic_device);mod_timer (&heartbeat_timer, jiffies +HZ /2 );register_restart_handler (&xt2000_restart_block); +register_sys_off_handler (SYS_OFF_MODE_POWER_OFF , +SYS_OFF_PRIO_DEFAULT , + xt2000_power_off,NULL );return 0 ; }
arch/xtensa/platforms/xtfpga/setup.c +5 -9
@@ -33,20 +33,13 @@#include <platform/lcd.h> #include <platform/hardware.h> -void platform_halt (void ) -{ -lcd_disp_at_pos (" HALT " ,0 ); -local_irq_disable (); -while (1 ) -cpu_relax (); -} - -void platform_power_off (void ) +static int xtfpga_power_off (struct sys_off_data *unused) {lcd_disp_at_pos ("POWEROFF" ,0 );local_irq_disable ();while (1 )cpu_relax (); +return NOTIFY_DONE ; } static int xtfpga_restart(struct notifier_block *this,
@@ -79,6 +72,9 @@ void __init platform_calibrate_ccount(void)static void __init xtfpga_register_handlers (void ) {register_restart_handler (&xtfpga_restart_block); +register_sys_off_handler (SYS_OFF_MODE_POWER_OFF , +SYS_OFF_PRIO_DEFAULT , + xtfpga_power_off,NULL ); }#ifdef CONFIG_USE_OF
Signature · 1 line
2.30.2
Max Filippov
maintainerPATCH 5/5 xtensa: clean up default platform functions
In reply to Max FilippovDrop _F macro used to define default platform functions and rewrite definitions as normal functions. Don't define separate __platform_* function and platform_* weak alias, just define a weak function.
--- arch/xtensa/kernel/platform.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
arch/xtensa/kernel/platform.c +15 -10
@@ -17,23 +17,28 @@#include <asm/platform.h> #include <asm/timex.h> -#define _F (r,f,a,b) \ - r __platform_##f a b; \ - r platform_##f a __attribute__((weak, alias("__platform_"#f))) -/* * Default functions that are used if no platform specific function is defined. -* (Please, refer to include/asm-xtensa/platform.h for more information) +* (Please, refer to arch/xtensa/include/asm/platform.h for more information) */ -_F (void, init, (bp_tag_t *first), { }); -_F(void, setup, (char** cmd), { }); -_F(void, idle, (void), { __asm__ __volatile__ ("waiti 0" ::: "memory"); }); +void __weak __init platform_init (bp_tag_t *first) +{ +} + +void __weak __init platform_setup (char **cmd) +{ +} + +void __weak platform_idle (void ) +{ + __asm__ __volatile__ ("waiti 0" :::"memory" ); +}#ifdef CONFIG_XTENSA_CALIBRATE_CCOUNT -_F(void, calibrate_ccount, (void), +void __weak platform_calibrate_ccount (void ) {pr_err ("ERROR: Cannot calibrate cpu frequency! Assuming 10MHz.\n" ); ccount_freq =10 *1000000UL ; -}); +}#endif
Signature · 1 line
2.30.2