powernv/opal: Introduce new opal_oppanel interface to expose the op_panel
Suraj Jitindar Singh
maintainerRFC PATCH 1/3 powernv/opal: Introduce new opal_oppanel interface to expose the op_panel
IBM PowerNV machines with FSPs have an operator panel with a LCD display. Currently this oppanel display can be accessed through the powernv_op_panel kernel module. We would like to be able to access this display easily from other places in the Kernel.
Add a new interface through which the operator panel display can be accessed from within the kernel. The function opal_oppanel_write acts like a print function and will respect newline and carriage return characters while trying to print the input to the display. The function opal_oppanel_read will provide access to what is currently in the display buffer.
--- MAINTAINERS | 1 + arch/powerpc/include/asm/opal.h | 7 + arch/powerpc/platforms/powernv/Kconfig | 4 + arch/powerpc/platforms/powernv/Makefile | 1 + arch/powerpc/platforms/powernv/opal-oppanel.c | 292 ++++++++++++++++++++++++++ drivers/char/Kconfig | 1 + 6 files changed, 306 insertions(+) create mode 100644 arch/powerpc/platforms/powernv/opal-oppanel.c
MAINTAINERS +1 -0
@@ -9218,6 +9218,7 @@ M: Suraj Jitindar Singh <[email protected]> L: [email protected] S: Maintained F: drivers/char/powernv-op-panel.c +F: arch/powerpc/platforms/powernv/opal-oppanel.c PNP SUPPORT M: "Rafael J. Wysocki" <[email protected]>
arch/powerpc/include/asm/opal.h +7 -0
@@ -286,6 +286,13 @@ static inline int opal_get_async_rc(struct opal_msg msg)return be64_to_cpu (msg.params[1 ]); } +#if defined(CONFIG_POWERNV_OP_PANEL ) || defined(CONFIG_POWERNV_OP_PANEL_MODULE ) +extern int opal_oppanel_write (char *msg); +extern void opal_oppanel_read (char *msg); +extern void opal_oppanel_get_size (u32 *size); +extern int opal_oppanel_init (void ); +#endif /* CONFIG_POWERNV_OP_PANEL */ +#endif /* __ASSEMBLY__ */ #endif /* _ASM_POWERPC_OPAL_H */
arch/powerpc/platforms/powernv/Kconfig +4 -0
@@ -26,3 +26,7 @@ config OPAL_PRD help This enables the opal-prd driver, a facility to run processor recovery diagnostics on OpenPower machines + +config POWERNV_OP_PANEL_BASE + bool + default n
arch/powerpc/platforms/powernv/Makefile +1 -0
@@ -11,3 +11,4 @@ obj-$(CONFIG_PPC_SCOM) += opal-xscom.o obj-$(CONFIG_MEMORY_FAILURE) += opal-memory-errors.o obj-$(CONFIG_TRACEPOINTS) += opal-tracepoints.o obj-$(CONFIG_OPAL_PRD) += opal-prd.o +obj-$(CONFIG_POWERNV_OP_PANEL_BASE) += opal-oppanel.o
arch/powerpc/platforms/powernv/opal-oppanel.c new file +292 -0
292 lines not on this page · raw message
drivers/char/Kconfig +1 -0
@@ -181,6 +181,7 @@ config IBM_BSR config POWERNV_OP_PANEL tristate "IBM POWERNV Operator Panel Display support" depends on PPC_POWERNV + select POWERNV_OP_PANEL_BASE help If you say Y here, a special character device node, /dev/op_panel, will be created which exposes the operator panel display on IBM
Signature · 1 line
2.5.5
Suraj Jitindar Singh
maintainerRFC PATCH 2/3 powernv/setup: Initialise opal_oppanel and display information on boot
Now that we have the ability to access the operator panel display from within the kernel print out some platform information on boot.
Update the opal initialisation function to call the init function for the new oppanel interface, this also removes the need to explicitly create the platform device as this is now handled in the oppanel init function.
Now that we are able to access the operator panel display from the kernel update the powernv platform progress function to write to the display. Add a function to print some platform information to the display on boot.
--- arch/powerpc/platforms/powernv/opal.c | 8 +++++--- arch/powerpc/platforms/powernv/setup.c | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-)
arch/powerpc/platforms/powernv/opal.c +5 -3
@@ -705,6 +705,11 @@ static int __init opal_init(void)/* Initialise OPAL asynchronous completion interface */ opal_async_comp_init (); +#if defined(CONFIG_POWERNV_OP_PANEL ) || defined(CONFIG_POWERNV_OP_PANEL_MODULE ) +/* Initialise OPAL oppanel interface */ +opal_oppanel_init (); +#endif /* CONFIG_POWERNV_OP_PANEL */ +/* Initialise OPAL sensor interface */ opal_sensor_init ();
@@ -751,9 +756,6 @@ static int __init opal_init(void)opal_pdev_init (opal_node,"ibm,opal-flash" );opal_pdev_init (opal_node,"ibm,opal-prd" ); -/* Initialise platform device: oppanel interface */ -opal_pdev_init (opal_node,"ibm,opal-oppanel" ); -/* Initialise OPAL kmsg dumper for flushing console on panic */ opal_kmsg_init ();
arch/powerpc/platforms/powernv/setup.c +27 -0
@@ -27,6 +27,7 @@#include <linux/interrupt.h> #include <linux/bug.h> #include <linux/pci.h> +#include <linux/utsname.h> #include <linux/cpufreq.h> #include <asm/machdep.h>
@@ -58,6 +59,29 @@ static void __init pnv_setup_arch(void)/* XXX PMCS */ } +static int __init pnv_late_init (void ) +{ +#if defined(CONFIG_POWERNV_OP_PANEL ) || defined(CONFIG_POWERNV_OP_PANEL_MODULE ) +char msg[17 ] = {'\0' }; +#endif /* CONFIG_POWERNV_OP_PANEL */ +/* Manually leave the kernel version on the panel */ +#ifdef __BIG_ENDIAN__ + ppc_md.progress ("Linux ppc64\n" ,0 ); +#else + ppc_md.progress ("Linux ppc64le\n" ,0 ); +#endif +#if defined(CONFIG_POWERNV_OP_PANEL ) || defined(CONFIG_POWERNV_OP_PANEL_MODULE ) +/* Limit what we print to 16 chars so the previous line remains */ +memcpy (msg,init_utsname ()->release,16 ); + ppc_md.progress (msg,0 ); +#else + ppc_md.progress (init_utsname ()->release,0 ); +#endif /* CONFIG_POWERNV_OP_PANEL */ + +return 0 ; +} +machine_late_initcall (powernv, pnv_late_init); +static void __init pnv_init_early (void ) {/*
@@ -159,6 +183,9 @@ static void __noreturn pnv_halt(void)static void pnv_progress (char *s,unsigned short hex) { +#if defined(CONFIG_POWERNV_OP_PANEL ) || defined(CONFIG_POWERNV_OP_PANEL_MODULE ) +opal_oppanel_write (s); +#endif /* CONFIG_POWERNV_OP_PANEL */ }static void pnv_shutdown (void )
Signature · 1 line
2.5.5
Suraj Jitindar Singh
maintainerRFC PATCH 3/3 powernv/oppanel: Update op_panel module to utilise opal_oppanel interface
In reply to Suraj Jitindar SinghThe powernv_op_panel kernel module is used to expose the operator panel display present on IBM PowerNV machines with FSPs through the char device /dev/op_panel.
The new interface opal_oppanel which has been added to allow access to the operator panel display from within the kernel duplicates a lot of the module code. Thus update the powernv_op_panel kernel module to access the display through the opal_oppanel interface.
--- drivers/char/powernv-op-panel.c | 153 ++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 102 deletions(-)
drivers/char/powernv-op-panel.c +51 -102
@@ -17,7 +17,7 @@#include <linux/slab.h> #include <linux/platform_device.h> #include <linux/miscdevice.h> - +#include <linux/uaccess.h> #include <asm/opal.h> /*
@@ -28,106 +28,87 @@* operator panel. */ -static DEFINE_MUTEX (oppanel_mutex); +static DEFINE_MUTEX (oppanel_driver_mutex); -static u32 num_lines, oppanel_size; -static oppanel_line_t *oppanel_lines; -static char *oppanel_data; - -static loff_t oppanel_llseek (struct file *filp,loff_t offset,int whence) -{ -return fixed_size_llseek (filp, offset, whence, oppanel_size); -} +static u32 buf_size; +char *oppanel_buf;static ssize_t oppanel_read (struct file *filp,char __user *userbuf,size_t len,loff_t *f_pos) { -return simple_read_from_buffer (userbuf, len, f_pos, oppanel_data, - oppanel_size); -} +ssize_t ret; -static int __op_panel_update_display (void ) -{ -struct opal_msg msg; -int rc, token; - - token =opal_async_get_token_interruptible (); -if (token <0 ) { -if (token != -ERESTARTSYS ) -pr_debug ("Couldn't get OPAL async token [token=%d]\n" , - token); -return token; - } +if (*f_pos <0 ) +return -EINVAL ; +if (*f_pos >= (buf_size -1 ) || !len) +return 0 ; +if (len > (buf_size -1 - *f_pos)) + len = buf_size -1 - *f_pos; - rc =opal_write_oppanel_async (token, oppanel_lines, num_lines); -switch (rc) { -case OPAL_ASYNC_COMPLETION : - rc =opal_async_wait_response (token, &msg); -if (rc) { -pr_debug ("Failed to wait for async response [rc=%d]\n" , - rc); -break ; - } - rc =opal_get_async_rc (msg); -if (rc !=OPAL_SUCCESS ) { -pr_debug ("OPAL async call returned failed [rc=%d]\n" , - rc); -break ; - } -case OPAL_SUCCESS : -break ; -default : -pr_debug ("OPAL write op-panel call failed [rc=%d]\n" , rc); - } +opal_oppanel_read (oppanel_buf); + ret = len -copy_to_user (userbuf, &oppanel_buf[*f_pos], len); -opal_async_release_token (token); -return rc; +/* Nothing was copied */ +if (!ret) +return -EFAULT ; + + *f_pos += ret; + +return ret; }static ssize_t oppanel_write (struct file *filp,const char __user *userbuf,size_t len,loff_t *f_pos) { -loff_t f_pos_prev = *f_pos;ssize_t ret;int rc; -if (!*f_pos) -memset (oppanel_data,' ' , oppanel_size); -else if (*f_pos >= oppanel_size) -return -EFBIG ; +if (*f_pos <0 ) +return -EINVAL ; +if (!len) +return 0 ; +if (len >= buf_size) + len = buf_size -1 ; - ret =simple_write_to_buffer (oppanel_data, oppanel_size, f_pos, userbuf, - len); + ret = len -copy_from_user (oppanel_buf, userbuf, len); +/* Something was copied */ if (ret >0 ) { - rc =__op_panel_update_display (); +/* Add null terminator */ + oppanel_buf[ret] ='\0' ; + rc =opal_oppanel_write (oppanel_buf);if (rc !=OPAL_SUCCESS ) {pr_err_ratelimited ("OPAL call failed to write to op panel display [rc=%d]\n" , rc); - *f_pos = f_pos_prev; -return -EIO ; +return rc; } - } +/* Nothing was copied */ + }else if (!ret) +return -EFAULT ; + + *f_pos += ret; +return ret; }static int oppanel_open (struct inode *inode,struct file *filp) { -if (!mutex_trylock (&oppanel_mutex)) { +if (!mutex_trylock (&oppanel_driver_mutex)) {pr_debug ("Device Busy\n" );return -EBUSY ; } +nonseekable_open (inode, filp);return 0 ; }static int oppanel_release (struct inode *inode,struct file *filp) { -mutex_unlock (&oppanel_mutex); +mutex_unlock (&oppanel_driver_mutex);return 0 ; }static const struct file_operations oppanel_fops = { .owner =THIS_MODULE , - .llseek = oppanel_llseek, + .llseek = no_llseek, .read = oppanel_read, .write = oppanel_write, .open = oppanel_open,
@@ -142,62 +123,30 @@ static struct miscdevice oppanel_dev = {static int oppanel_probe (struct platform_device *pdev) { -struct device_node *np = pdev->dev.of_node; -u32 line_len; -int rc, i; - - rc =of_property_read_u32 (np,"#length" , &line_len); -if (rc) { -pr_err_ratelimited ("Operator panel length property not found\n" ); -return rc; - } - rc =of_property_read_u32 (np,"#lines" , &num_lines); -if (rc) { -pr_err_ratelimited ("Operator panel lines property not found\n" ); -return rc; - } - oppanel_size = line_len * num_lines; +int rc; -pr_devel ("Operator panel of size %u found with %u lines of length %u\n" , - oppanel_size, num_lines, line_len); +opal_oppanel_get_size (&buf_size); +/* Add space for a null terminator */ + buf_size +=1 ; - oppanel_data =kcalloc (oppanel_size,sizeof (*oppanel_data),GFP_KERNEL ); -if (!oppanel_data) + oppanel_buf =kcalloc (buf_size,sizeof (*oppanel_buf),GFP_KERNEL ); +if (!oppanel_buf)return -ENOMEM ; - - oppanel_lines =kcalloc (num_lines,sizeof (oppanel_line_t),GFP_KERNEL ); -if (!oppanel_lines) { - rc = -ENOMEM ; - goto free_oppanel_data; - } - -memset (oppanel_data,' ' , oppanel_size); -for (i =0 ; i < num_lines; i++) { - oppanel_lines[i].line_len =cpu_to_be64 (line_len); - oppanel_lines[i].line =cpu_to_be64 (__pa (&oppanel_data[i * - line_len])); - } +memset (oppanel_buf,'\0' , buf_size); rc =misc_register (&oppanel_dev);if (rc) {pr_err_ratelimited ("Failed to register as misc device\n" ); - goto free_oppanel; +kfree (oppanel_buf); } -return 0 ; - -free_oppanel: -kfree (oppanel_lines); -free_oppanel_data: -kfree (oppanel_data);return rc; }static int oppanel_remove (struct platform_device *pdev) {misc_deregister (&oppanel_dev); -kfree (oppanel_lines); -kfree (oppanel_data); +kfree (oppanel_buf);return 0 ; }
Signature · 1 line
2.5.5