Series short description
Subsystems (4)
cover Series short description
This patch set updates the intel SCU IPC to our internal version and fixes various bugs/cleanliness issues as well as making the CPU detection occur automatically and removing the module parameter.
---
Alan Cox (1):
intel_scu_ipc: Use the new cpu identification function
Andy Ross (1):
Clean up command packing on MRST.
Arjan van de Ven (2):
zero the stack buffer before giving random garbage to the SCU Fix stack buffer size for IPC writev messages
Hong Liu (3):
intel_scu_ipc: fix size field for intel_scu_ipc_command
intel_scu_ipc: return -EIO for error condition in busy_loop
Sreedhara DS (4):
intel_scu_ipc: tidy up unused bits Remove indirect read write api support.
intel_scu_ipc: Support Medfield processors
intel_scu_ipc: detect CPU type automatically
arch/x86/include/asm/intel_scu_ipc.h | 14 --- drivers/platform/x86/intel_scu_ipc.c | 180 ++++++++++------------------------ 2 files changed, 52 insertions(+), 142 deletions(-)
Signature · 2 lines
"It's 106 miles to Chicago, we've got a full tank of gas, the sat-nav has crashed, it's dark and we're completely lost"
PATCH 1/11 intel_scu_ipc: detect CPU type automatically
From: Sreedhara DS <[email protected]>
Intel SCU message formats depend upon the processor type. Replace the module option with automatic detection of the processor type.
---
drivers/platform/x86/intel_scu_ipc.c | 19 ++++++++++++------- 1 files changed, 12 insertions(+), 7 deletions(-)
drivers/platform/x86/intel_scu_ipc.c +12 -7
@@ -23,7 +23,7 @@#include <linux/pm.h> #include <linux/pci.h> #include <linux/interrupt.h> -#include <asm/setup.h> +#include <asm/mrst.h> #include <asm/intel_scu_ipc.h> /* IPC defines the following message types */
@@ -78,12 +78,9 @@ struct intel_scu_ipc_dev {static struct intel_scu_ipc_dev ipcdev;/* Only one for now */ -static int platform =1 ; -module_param (platform, int,0 ); -MODULE_PARM_DESC (platform,"1 for moorestown platform" ); - - - +#define PLATFORM_LANGWELL 1 +#define PLATFORM_PENWELL 2 +static int platform;/* Platform type */ /* * IPC Read Buffer (Read Only):
@@ -817,6 +814,14 @@ static struct pci_driver ipc_driver = {static int __init intel_scu_ipc_init (void ) { +if (boot_cpu_data.x86 ==6 && + boot_cpu_data.x86_model ==0x27 && + boot_cpu_data.x86_mask ==1 ) + platform =PLATFORM_PENWELL ; +else if (boot_cpu_data.x86 ==6 && + boot_cpu_data.x86_model ==0x26 ) + platform =PLATFORM_LANGWELL ; +return pci_register_driver (&ipc_driver); }
PATCH 2/11 intel_scu_ipc: Support Medfield processors
In reply to Alan CoxFrom: Sreedhara DS <[email protected]>
Changes to work on bothMmoorestown and Medfield New pci id added for Medfield
Return type of ipc_data_readl chnaged from u8 to u32
---
drivers/platform/x86/intel_scu_ipc.c | 53 +++++++++++++++++++++------------- 1 files changed, 33 insertions(+), 20 deletions(-)
drivers/platform/x86/intel_scu_ipc.c +33 -20
@@ -151,7 +151,7 @@ static inline u8 ipc_data_readb(u32 offset) /* Read ipc byte data */return readb (ipcdev.ipc_base +IPC_READ_BUFFER + offset); } -static inline u8 ipc_data_readl (u32 offset)/* Read ipc u32 data */ +static inline u32 ipc_data_readl (u32 offset)/* Read ipc u32 data */ {return readl (ipcdev.ipc_base +IPC_READ_BUFFER + offset); }
@@ -181,18 +181,19 @@ static int pwr_reg_rdwr(u16 *addr, u8 *data, u32 count, u32 op, u32 id)int nc;u32 offset =0 ;u32 err =0 ; -u8 cbuf[IPC_WWBUF_SIZE ] = {'\0' }; +u8 cbuf[IPC_WWBUF_SIZE ] = { };u32 *wbuf = (u32 *)&cbuf;mutex_lock (&ipclock); +if (ipcdev.pdev ==NULL ) {mutex_unlock (&ipclock);return -ENODEV ; } -if (platform ==1 ) { +if (platform ==PLATFORM_LANGWELL ) {/* Entry is 4 bytes for read/write, 5 bytes for read modify */ -for (nc =0 ; nc < count; nc++) { +for (nc =0 ; nc < count; nc++, offset +=3 ) { cbuf[offset] = addr[nc]; cbuf[offset +1 ] = addr[nc] >>8 ;if (id !=IPC_CMD_PCNTRL_R )
@@ -201,33 +202,44 @@ static int pwr_reg_rdwr(u16 *addr, u8 *data, u32 count, u32 op, u32 id) cbuf[offset +3 ] = data[nc +1 ]; offset +=1 ; } - offset +=3 ; }for (nc =0 , offset =0 ; nc < count; nc++, offset +=4 )ipc_data_writel (wbuf[nc], offset);/* Write wbuff */ +if (id !=IPC_CMD_PCNTRL_M ) +ipc_command ((count*4 ) <<16 | id <<12 |0 <<8 | op); +else +ipc_command ((count*5 ) <<16 | id <<12 |0 <<8 | op); + }else { -for (nc =0 , offset =0 ; nc < count; nc++, offset +=2 ) -ipc_data_writel (addr[nc], offset);/* Write addresses */ -if (id !=IPC_CMD_PCNTRL_R ) { -for (nc =0 ; nc < count; nc++, offset++) -ipc_data_writel (data[nc], offset);/* Write data */ -if (id ==IPC_CMD_PCNTRL_M ) -ipc_data_writel (data[nc +1 ], offset);/* Mask value*/ +for (nc =0 ; nc < count; nc++, offset +=2 ) { + cbuf[offset] = addr[nc]; + cbuf[offset +1 ] = addr[nc] >>8 ; } - } -if (id !=IPC_CMD_PCNTRL_M ) -ipc_command ((count *3 ) <<16 | id <<12 |0 <<8 | op); -else -ipc_command ((count *4 ) <<16 | id <<12 |0 <<8 | op); +if (id ==IPC_CMD_PCNTRL_R ) { +for (nc =0 , offset =0 ; nc < count; nc++, offset +=4 ) +ipc_data_writel (wbuf[nc], offset); +ipc_command ((count*2 ) <<16 | id <<12 |0 <<8 | op); + }else if (id ==IPC_CMD_PCNTRL_W ) { +for (nc =0 ; nc < count; nc++, offset +=1 ) + cbuf[offset] = data[nc]; +for (nc =0 , offset =0 ; nc < count; nc++, offset +=4 ) +ipc_data_writel (wbuf[nc], offset); +ipc_command ((count*3 ) <<16 | id <<12 |0 <<8 | op); + }else if (id ==IPC_CMD_PCNTRL_M ) { + cbuf[offset] = data[0 ]; + cbuf[offset +1 ] = data[1 ]; +ipc_data_writel (wbuf[0 ],0 );/* Write wbuff */ +ipc_command (4 <<16 | id <<12 |0 <<8 | op); + } + } err =busy_loop (); -if (id ==IPC_CMD_PCNTRL_R ) {/* Read rbuf */ /* Workaround: values are read as 0 without memcpy_fromio */ -memcpy_fromio (cbuf, ipcdev.ipc_base +IPC_READ_BUFFER ,16 ); -if (platform ==1 ) { +memcpy_fromio (cbuf, ipcdev.ipc_base +0x90 ,16 ); +if (platform ==PLATFORM_LANGWELL ) {for (nc =0 , offset =2 ; nc < count; nc++, offset +=3 ) data[nc] =ipc_data_readb (offset); }else {
@@ -800,6 +812,7 @@ static void ipc_remove(struct pci_dev *pdev)static const struct pci_device_id pci_ids[] = { {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,0x080e )}, + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,0x082a )}, {0 ,} };MODULE_DEVICE_TABLE (pci, pci_ids);
PATCH 3/11 Remove indirect read write api support.
In reply to Alan CoxFrom: Sreedhara DS <[email protected]>
The firmware of production devices does not support this interface so this is dead code.
---
arch/x86/include/asm/intel_scu_ipc.h | 14 ------ drivers/platform/x86/intel_scu_ipc.c | 82 ---------------------------------- 2 files changed, 0 insertions(+), 96 deletions(-)
arch/x86/include/asm/intel_scu_ipc.h +0 -14
@@ -34,20 +34,6 @@ int intel_scu_ipc_writev(u16 *addr, u8 *data, int len);/* Update single register based on the mask */ int intel_scu_ipc_update_register (u16 addr,u8 data,u8 mask); -/* -* Indirect register read -* Can be used when SCCB(System Controller Configuration Block) register -* HRIM(Honor Restricted IPC Messages) is set (bit 23) -*/ -int intel_scu_ipc_register_read (u32 addr,u32 *data); - -/* -* Indirect register write -* Can be used when SCCB(System Controller Configuration Block) register -* HRIM(Honor Restricted IPC Messages) is set (bit 23) -*/ -int intel_scu_ipc_register_write (u32 addr,u32 data); -/* Issue commands to the SCU with or without data */ int intel_scu_ipc_simple_command (int cmd,int sub); int intel_scu_ipc_command(int cmd, int sub, u32 *in, int inlen,
drivers/platform/x86/intel_scu_ipc.c +0 -82
94 lines not on this page · raw message
PATCH 4/11 intel_scu_ipc: tidy up unused bits
In reply to Alan CoxFrom: Sreedhara DS <[email protected]>
Delete unused constants IPC_CMD_INDIRECT_RD and IPC_CMD_INDIRECT_WR Remove multiple inclusion of header file "asm/mrst.h"
---
drivers/platform/x86/intel_scu_ipc.c | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)
drivers/platform/x86/intel_scu_ipc.c +0 -4
@@ -38,10 +38,6 @@#define IPC_CMD_PCNTRL_R 1/* Register read */ #define IPC_CMD_PCNTRL_M 2/* Register read-modify-write */ -/* Miscelaneous Command ids */ -#define IPC_CMD_INDIRECT_RD 2/* 32bit indirect read */ -#define IPC_CMD_INDIRECT_WR 5/* 32bit indirect write */ -/* * IPC register summary *
PATCH 5/11 intel_scu_ipc: Use the new cpu identification function
In reply to Alan CoxThis provides an architecture level board identify function to replace the cpuid direct usage
---
drivers/platform/x86/intel_scu_ipc.c | 17 +++++------------ 1 files changed, 5 insertions(+), 12 deletions(-)
drivers/platform/x86/intel_scu_ipc.c +5 -12
@@ -74,8 +74,6 @@ struct intel_scu_ipc_dev {static struct intel_scu_ipc_dev ipcdev;/* Only one for now */ -#define PLATFORM_LANGWELL 1 -#define PLATFORM_PENWELL 2static int platform;/* Platform type */ /*
@@ -169,7 +167,7 @@ static int pwr_reg_rdwr(u16 *addr, u8 *data, u32 count, u32 op, u32 id)return -ENODEV ; } -if (platform ==PLATFORM_LANGWELL ) { +if (platform !=MRST_CPU_CHIP_PENWELL ) {/* Entry is 4 bytes for read/write, 5 bytes for read modify */ for (nc =0 ; nc < count; nc++, offset +=3 ) { cbuf[offset] = addr[nc];
@@ -217,7 +215,7 @@ static int pwr_reg_rdwr(u16 *addr, u8 *data, u32 count, u32 op, u32 id)if (id ==IPC_CMD_PCNTRL_R ) {/* Read rbuf */ /* Workaround: values are read as 0 without memcpy_fromio */ memcpy_fromio (cbuf, ipcdev.ipc_base +0x90 ,16 ); -if (platform ==PLATFORM_LANGWELL ) { +if (platform !=MRST_CPU_CHIP_PENWELL ) {for (nc =0 , offset =2 ; nc < count; nc++, offset +=3 ) data[nc] =ipc_data_readb (offset); }else {
@@ -741,14 +739,9 @@ static struct pci_driver ipc_driver = {static int __init intel_scu_ipc_init (void ) { -if (boot_cpu_data.x86 ==6 && - boot_cpu_data.x86_model ==0x27 && - boot_cpu_data.x86_mask ==1 ) - platform =PLATFORM_PENWELL ; -else if (boot_cpu_data.x86 ==6 && - boot_cpu_data.x86_model ==0x26 ) - platform =PLATFORM_LANGWELL ; - + platform =mrst_identify_cpu (); +if (platform ==0 ) +return -ENODEV ;return pci_register_driver (&ipc_driver); }
PATCH 6/11 Fix stack buffer size for IPC writev messages
In reply to Alan CoxFrom: Arjan van de Ven <[email protected]>
The stack buffer for IPC messages was 16 bytes, limiting messages to a size of 4 (each message is 32 bit).
However, the touch screen driver is trying to send messages of size 5....
(AC: Set to 20 bytes having checked the max size allowed)
---
drivers/platform/x86/intel_scu_ipc.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/intel_scu_ipc.c +2 -2
@@ -58,8 +58,8 @@#define IPC_BASE_ADDR 0xFF11C000/* IPC1 base register address */ #define IPC_MAX_ADDR 0x100/* Maximum IPC regisers */ -#define IPC_WWBUF_SIZE 16/* IPC Write buffer Size */ -#define IPC_RWBUF_SIZE 16/* IPC Read buffer Size */ +#define IPC_WWBUF_SIZE 20/* IPC Write buffer Size */ +#define IPC_RWBUF_SIZE 20/* IPC Read buffer Size */ #define IPC_I2C_BASE 0xFF12B000/* I2C control register base address */ #define IPC_I2C_MAX_ADDR 0x10/* Maximum I2C regisers */
PATCH 7/11 zero the stack buffer before giving random garbage to the SCU
In reply to Alan CoxFrom: Arjan van de Ven <[email protected]>
some messages take 4 bytes, but only fill 3 bytes....
this patch makes sure that whatever we send to the SCU is zeroed first
---
drivers/platform/x86/intel_scu_ipc.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/platform/x86/intel_scu_ipc.c +2 -0
@@ -162,6 +162,8 @@ static int pwr_reg_rdwr(u16 *addr, u8 *data, u32 count, u32 op, u32 id)mutex_lock (&ipclock); +memset (cbuf,0 ,sizeof (cbuf)); +if (ipcdev.pdev ==NULL ) {mutex_unlock (&ipclock);return -ENODEV ;
PATCH 8/11 Clean up command packing on MRST.
In reply to Alan CoxFrom: Andy Ross <[email protected]>
Don't pass more bytes in the command length field than we filled.
---
drivers/platform/x86/intel_scu_ipc.c | 29 +++++++++++------------------ 1 files changed, 11 insertions(+), 18 deletions(-)
drivers/platform/x86/intel_scu_ipc.c +11 -18
@@ -154,7 +154,7 @@ static inline int busy_loop(void) /* Wait till scu status is busy *//* Read/Write power control(PMIC in Langwell, MSIC in PenWell) registers */ static int pwr_reg_rdwr (u16 *addr,u8 *data,u32 count,u32 op,u32 id) { -int nc; +int i, nc, bytes;u32 offset =0 ;u32 err =0 ;u8 cbuf[IPC_WWBUF_SIZE ] = { };
@@ -170,25 +170,18 @@ static int pwr_reg_rdwr(u16 *addr, u8 *data, u32 count, u32 op, u32 id) }if (platform !=MRST_CPU_CHIP_PENWELL ) { -/* Entry is 4 bytes for read/write, 5 bytes for read modify */ -for (nc =0 ; nc < count; nc++, offset +=3 ) { - cbuf[offset] = addr[nc]; - cbuf[offset +1 ] = addr[nc] >>8 ; + bytes =0 ; +for (i=0 ; i<count; i++) { + cbuf[bytes++] = addr[i]; + cbuf[bytes++] = addr[i] >>8 ;if (id !=IPC_CMD_PCNTRL_R ) - cbuf[offset +2 ] = data[nc]; -if (id ==IPC_CMD_PCNTRL_M ) { - cbuf[offset +3 ] = data[nc +1 ]; - offset +=1 ; - } + cbuf[bytes++] = data[i]; +if (id ==IPC_CMD_PCNTRL_M ) + cbuf[bytes++] = data[i +1 ]; } -for (nc =0 , offset =0 ; nc < count; nc++, offset +=4 ) -ipc_data_writel (wbuf[nc], offset);/* Write wbuff */ - -if (id !=IPC_CMD_PCNTRL_M ) -ipc_command ((count*4 ) <<16 | id <<12 |0 <<8 | op); -else -ipc_command ((count*5 ) <<16 | id <<12 |0 <<8 | op); - +for (i=0 ; i<bytes; i+=4 ) +ipc_data_writel (wbuf[i/4 ], i); +ipc_command (bytes <<16 | id <<12 |0 <<8 | op); }else {for (nc =0 ; nc < count; nc++, offset +=2 ) { cbuf[offset] = addr[nc];
PATCH 9/11 intel_scu_ipc: fix data packing of PMIC command on Moorestown
In reply to Alan CoxFrom: Hong Liu <[email protected]>
Data is 2-byte per entry for PMIC read-modify-update command.
---
drivers/platform/x86/intel_scu_ipc.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-)
drivers/platform/x86/intel_scu_ipc.c +6 -5
@@ -154,7 +154,7 @@ static inline int busy_loop(void) /* Wait till scu status is busy *//* Read/Write power control(PMIC in Langwell, MSIC in PenWell) registers */ static int pwr_reg_rdwr (u16 *addr,u8 *data,u32 count,u32 op,u32 id) { -int i, nc, bytes; +int i, nc, bytes, d;u32 offset =0 ;u32 err =0 ;u8 cbuf[IPC_WWBUF_SIZE ] = { };
@@ -171,15 +171,16 @@ static int pwr_reg_rdwr(u16 *addr, u8 *data, u32 count, u32 op, u32 id)if (platform !=MRST_CPU_CHIP_PENWELL ) { bytes =0 ; -for (i=0 ; i<count; i++) { + d =0 ; +for (i =0 ; i < count; i++) { cbuf[bytes++] = addr[i]; cbuf[bytes++] = addr[i] >>8 ;if (id !=IPC_CMD_PCNTRL_R ) - cbuf[bytes++] = data[i]; + cbuf[bytes++] = data[d++];if (id ==IPC_CMD_PCNTRL_M ) - cbuf[bytes++] = data[i +1 ]; + cbuf[bytes++] = data[d++]; } -for (i=0 ; i<bytes; i+=4 ) +for (i =0 ; i < bytes; i +=4 )ipc_data_writel (wbuf[i/4 ], i);ipc_command (bytes <<16 | id <<12 |0 <<8 | op); }else {
PATCH 10/11 intel_scu_ipc: return -EIO for error condition in busy_loop
In reply to Alan CoxFrom: Hong Liu <[email protected]>
---
drivers/platform/x86/intel_scu_ipc.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/platform/x86/intel_scu_ipc.c +4 -1
@@ -148,7 +148,10 @@ static inline int busy_loop(void) /* Wait till scu status is busy */return -ETIMEDOUT ; } } -return (status >>1 ) &1 ; +if ((status >>1 ) &1 ) +return -EIO ; + +return 0 ; }/* Read/Write power control(PMIC in Langwell, MSIC in PenWell) registers */
PATCH 11/11 intel_scu_ipc: fix size field for intel_scu_ipc_command
In reply to Alan CoxFrom: Hong Liu <[email protected]>
Size for PMIC read/write command is byte, while it is DWORD for other IPC commands.
---
drivers/platform/x86/intel_scu_ipc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/platform/x86/intel_scu_ipc.c +1 -1
@@ -444,7 +444,7 @@ int intel_scu_ipc_command(int cmd, int sub, u32 *in, int inlen,for (i =0 ; i < inlen; i++)ipc_data_writel (*in++,4 * i); -ipc_command ((sub <<12 ) | cmd | (inlen <<18 )); +ipc_command ((inlen <<16 ) | (sub <<12 ) | cmd); err =busy_loop ();for (i =0 ; i < outlen; i++)
Matthew Garrett
AppliedThanks, applied.
Signature · 1 line
Matthew Garrett | [email protected]