Enable more Intel Mid platforms on IPC driver
cover Enable more Intel Mid platforms on IPC driver
Hi,
I am resubmitting these patches to enable other Intel Mid platforms on IPC driver.
This change is necessary prior to enable more features for Mid on upstream.
Br, David Cohen
---
Kuppuswamy Sathyanarayanan (3):
ipc: Added platform data structure
ipc: Enabled ipc support for additional intel platforms
ipc: Added support for IPC interrupt mode
drivers/platform/x86/Kconfig | 23 +++++++ drivers/platform/x86/intel_scu_ipc.c | 114 +++++++++++++++++++++++++++++++---- 2 files changed, 126 insertions(+), 11 deletions(-)
Signature · 1 line
1.8.4.2
PATCH 1/3 ipc: Added platform data structure
From: Kuppuswamy Sathyanarayanan <[email protected]>
Since the same ipc driver can be used by many platforms, using macros for defining ipc_base and i2c_base addresses is not a scalable approach. So added a platform data structure to pass this information.
--- drivers/platform/x86/intel_scu_ipc.c | 37 ++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-)
drivers/platform/x86/intel_scu_ipc.c +29 -8
@@ -58,12 +58,29 @@* message handler is called within firmware. */ -#define IPC_BASE_ADDR 0xFF11C000/* IPC1 base register address */ -#define IPC_MAX_ADDR 0x100/* Maximum IPC regisers */ #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 */ + +enum { +SCU_IPC_LINCROFT , +}; + +/* intel scu ipc driver data*/ +struct intel_scu_ipc_pdata_t { +u32 ipc_base; +u32 i2c_base; +u32 ipc_len; +u32 i2c_len; +}; + +static struct intel_scu_ipc_pdata_t intel_scu_ipc_pdata[] = { + [SCU_IPC_LINCROFT ] = { + .ipc_base =0xff11c000 , + .i2c_base =0xff12b000 , + .ipc_len =0x100 , + .i2c_len =0x10 , + }, +};static int ipc_probe (struct pci_dev *dev,const struct pci_device_id *id);static void ipc_remove (struct pci_dev *pdev);
@@ -504,12 +521,16 @@ static irqreturn_t ioc(int irq, void *dev_id)*/ static int ipc_probe (struct pci_dev *dev,const struct pci_device_id *id) { -int err; +int err, pid; +struct intel_scu_ipc_pdata_t *pdata;resource_size_t pci_resource;if (ipcdev.pdev)/* We support only one SCU */ return -EBUSY ; + pid = id->driver_data; + pdata = &intel_scu_ipc_pdata[pid]; + ipcdev.pdev =pci_dev_get (dev); err =pci_enable_device (dev);
@@ -527,11 +548,11 @@ static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id)if (request_irq (dev->irq, ioc,0 ,"intel_scu_ipc" , &ipcdev))return -EBUSY ; - ipcdev.ipc_base =ioremap_nocache (IPC_BASE_ADDR ,IPC_MAX_ADDR ); + ipcdev.ipc_base =ioremap_nocache (pdata->ipc_base, pdata->ipc_len);if (!ipcdev.ipc_base)return -ENOMEM ; - ipcdev.i2c_base =ioremap_nocache (IPC_I2C_BASE ,IPC_I2C_MAX_ADDR ); + ipcdev.i2c_base =ioremap_nocache (pdata->i2c_base, pdata->i2c_len);if (!ipcdev.i2c_base) {iounmap (ipcdev.ipc_base);return -ENOMEM ;
@@ -564,7 +585,7 @@ static void ipc_remove(struct pci_dev *pdev) }static DEFINE_PCI_DEVICE_TABLE (pci_ids) = { - {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,0x082a )}, + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,0x082a ),SCU_IPC_LINCROFT }, {0 ,} };MODULE_DEVICE_TABLE (pci, pci_ids);
Signature · 1 line
1.8.4.2
Re: [PATCH 1/3] ipc: Added platform data structure
Quoted 9 lines · On Wed, 13 Nov 2013 12:14:29 -0800 David Cohen <[email protected]>…
From: Kuppuswamy Sathyanarayanan <[email protected]>
Since the same ipc driver can be used by many platforms, using macros for defining
ipc_baseandi2c_baseaddresses is not a scalable approach. So added a platform data structure to pass this information.Signed-off-by Kuppuswamy Sathyanarayanan <[email protected]>Cc David Cohen <[email protected]>
PATCH 2/3 ipc: Enabled ipc support for additional intel platforms
In reply to David CohenFrom: Kuppuswamy Sathyanarayanan <[email protected]>
Enabled ipc support for penwell, clovertrail & tangier platforms.
--- drivers/platform/x86/intel_scu_ipc.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/platform/x86/intel_scu_ipc.c +24 -0
@@ -63,6 +63,9 @@enum {SCU_IPC_LINCROFT , +SCU_IPC_PENWELL , +SCU_IPC_CLOVERVIEW , +SCU_IPC_TANGIER , };/* intel scu ipc driver data*/
@@ -80,6 +83,24 @@ static struct intel_scu_ipc_pdata_t intel_scu_ipc_pdata[] = { .ipc_len = 0x100, .i2c_len = 0x10, }, + [SCU_IPC_PENWELL] = { + .ipc_base = 0xff11c000, + .i2c_base = 0xff12b000, + .ipc_len = 0x100, + .i2c_len = 0x10, + }, + [SCU_IPC_CLOVERVIEW] = { + .ipc_base = 0xff11c000, + .i2c_base = 0xff12b000, + .ipc_len = 0x100, + .i2c_len = 0x10, + }, + [SCU_IPC_TANGIER] = { + .ipc_base = 0xff009000, + .i2c_base = 0xff00d000, + .ipc_len = 0x100, + .i2c_len = 0x10, + }, };static int ipc_probe (struct pci_dev *dev,const struct pci_device_id *id);
@@ -586,6 +607,9 @@ static void ipc_remove(struct pci_dev *pdev)static DEFINE_PCI_DEVICE_TABLE (pci_ids) = { {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,0x082a ),SCU_IPC_LINCROFT }, + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,0x080e ),SCU_IPC_PENWELL }, + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,0x08ea ),SCU_IPC_CLOVERVIEW }, + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,0x11a0 ),SCU_IPC_TANGIER }, {0 ,} };MODULE_DEVICE_TABLE (pci, pci_ids);
Signature · 1 line
1.8.4.2
Re: [PATCH 2/3] ipc: Enabled ipc support for additional intel platforms
Quoted 3 lines · On Wed, 13 Nov 2013 12:14:30 -0800 David Cohen <[email protected]>…
From: Kuppuswamy Sathyanarayanan <[email protected]>
Enabled ipc support for penwell, clovertrail & tangier platforms.
At some point this really ought to be discoverable in your SFI, ACPI or similar data tables not continually hard coded.
Alan
Re: [PATCH 2/3] ipc: Enabled ipc support for additional intel platforms
Quoted 9 lines · One Thousand Gnomes
Quoted 3 lines · On Wed, 13 Nov 2013 12:14:30 -0800 David Cohen <[email protected]>…
From: Kuppuswamy Sathyanarayanan <[email protected]>
Enabled ipc support for penwell, clovertrail & tangier platforms.
At some point this really ought to be discoverable in your SFI, ACPI or similar data tables not continually hard coded.
Agreed. But it depends on fw changes, which I believe to happen on newer platforms only. On driver side we need to fill the missing resource info with hardcoded values :/
Br, David
Re: [PATCH 2/3] ipc: Enabled ipc support for additional intel platforms
Quoted 6 lines · On Thu, 14 Nov 2013 09:31:38 -0800 David Cohen <[email protected]>…
Quoted 5 lines · One Thousand Gnomes
Quoted 2 lines · On Wed, 13 Nov 2013 12:14:30 -0800 David Cohen <[email protected]>…
From: Kuppuswamy Sathyanarayanan <[email protected]>
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Enabled ipc support for penwell, clovertrail & tangier platforms.
At some point this really ought to be discoverable in your SFI, ACPI or similar data tables not continually hard coded.
Agreed. But it depends on fw changes, which I believe to happen on newer platforms only. On driver side we need to fill the missing resource info with hardcoded values :/
Oh agreed entirely, but please twist the arms of those responsible and make sure they are very keen to get it into the firmware ACPI tables ASAP.. 8)
PATCH 3/3 ipc: Added support for IPC interrupt mode
In reply to David CohenFrom: Kuppuswamy Sathyanarayanan <[email protected]>
This patch adds support for ipc command interrupt mode.
Also added following access mode config options.
CONFIG_INTEL_SCU_IPC_INTR_MODE - Selecting this option will configure the driver to receive IOC interrupt for each successful ipc_command.
CONFIG_INTEL_SCU_IPC_POLL_MODE - Makes driver use polling method to track the command completion status.
--- drivers/platform/x86/Kconfig | 23 ++++++++++++++++ drivers/platform/x86/intel_scu_ipc.c | 53 ++++++++++++++++++++++++++++++++++-- 2 files changed, 73 insertions(+), 3 deletions(-)
drivers/platform/x86/Kconfig +23 -0
@@ -655,6 +655,29 @@ config INTEL_SCU_IPC some embedded Intel x86 platforms. This is not needed for PC-type machines. +choice + prompt "IPC access mode" + depends on INTEL_SCU_IPC + default INTEL_SCU_IPC_INTR_MODE + ---help--- + Select the desired access mode for IPC call. + +config INTEL_SCU_IPC_INTR_MODE + bool "Intel SCU IPC interrupt mode" + ---help--- + Selecting this option will configure the driver + to receive IOC interrupt for each successful + ipc_command. + + +config INTEL_SCU_IPC_POLL_MODE + bool "Intel SCU IPC polling mode" + ---help--- + Makes driver use polling method to track the + command completion status + +endchoice + config INTEL_SCU_IPC_UTIL tristate "Intel SCU IPC utility driver" depends on INTEL_SCU_IPC
drivers/platform/x86/intel_scu_ipc.c +50 -3
108 lines not on this page · raw message
Signature · 1 line
1.8.4.2
Re: [PATCH 3/3] ipc: Added support for IPC interrupt mode
O> + prompt "IPC access mode"
drivers/platform/x86/Kconfig config INTEL_SCU_IPC · line 663
Quoted 4 lines
drivers/platform/x86/Kconfig +4
-0+ depends on INTEL_SCU_IPC + default INTEL_SCU_IPC_INTR_MODE + ---help--- + Select the desired access mode for IPC call.
This seems to depend at runtime on the platform so ifdefs seem inappropriate.
drivers/platform/x86/intel_scu_ipc.c static DEFINE_MUTEX(ipclock); /* lock used to prevent multiple call to SCU */ · line 149
Quoted 9 lines
static inline void
ipc_command(u32 cmd)/* Send ipc command */ {drivers/platform/x86/intel_scu_ipc.c +5
-0+#ifdef CONFIG_INTEL_SCU_IPC_INTR_MODE +INIT_COMPLETION (ipcdev.cmd_complete); +writel (cmd |IPC_IOC , ipcdev.ipc_base); +#else writel (cmd, ipcdev.ipc_base); +#endif }
If this is platform specific then add an IRQ to your platform data and check for it then set an irq field in your scu objects and check at runtime. If it depends upon the command and/or user then pass irq as a parameter.
Quoted 15 lines
/*
drivers/platform/x86/intel_scu_ipc.c +9
-0@@ -194,6 +203,37 @@ static inline int busy_loop(void) /* Wait till scu status is busy */return 0 ; } +#ifdef CONFIG_INTEL_SCU_IPC_INTR_MODE +/* Wait till ipc ioc interrupt is received or timeout in 3 HZ */ +static inline int ipc_wait_for_interrupt (void ) +{ +int status; +int ret =0 ; + +if (!wait_for_completion_timeout (&ipcdev.cmd_complete,3 *HZ )) { + ret = -ETIMEDOUT ;
drivers/platform/x86/intel_scu_ipc.c static inline int busy_loop(void) /* Wait till scu status is busy */ · line 224
Quoted 10 lines
drivers/platform/x86/intel_scu_ipc.c +10
-0+ goto end; + } + + status =ipc_read_status (); + +if ((status >>1 ) &1 ) + ret = -EIO ; + +end: +return ret;
What happens on a timeout if the command then completes. Will it not potentially produce a bogus completion on the next command just being issued in some cases. Also it should probably be logged ?
So I think
1. Pass the informatio upon whether IRQ mode should be used in the platform information and remove all the ifdeffery
2. Log timeouts
3. Explain what happens on a timeout that allows you to issue further commands without a race - eg do you need to do any kind of reset or will the next command issue stall sufficiently etc ?
Alan
Re: [PATCH 3/3] ipc: Added support for IPC interrupt mode
Hi Alan,
[snip]
Quoted 4 lines
So I think
1. Pass the informatio upon whether IRQ mode should be used in the platform information and remove all the ifdeffery
I will double check with Sathya. But in case polling mode is left for development purpose, make we can create a static variable to set irq mode or not.
Quoted 1 line
2. Log timeouts
Agreed.
Quoted 3 lines
3. Explain what happens on a timeout that allows you to issue further commands without a race - eg do you need to do any kind of reset or will the next command issue stall sufficiently etc ?
I'll check with Sathya.
Thanks,
David Cohen
Re: [PATCH 3/3] ipc: Added support for IPC interrupt mode
Quoted 4 lines · On Thu, 14 Nov 2013 09:36:18 -0800 David Cohen <[email protected]>…
Hi Alan,
[snip]
Quoted 8 lines
Quoted 4 lines
So I think
1. Pass the informatio upon whether IRQ mode should be used in the platform information and remove all the ifdeffery
I will double check with Sathya. But in case polling mode is left for development purpose, make we can create a static variable to set irq mode or not.
If its only for development it doesn't IMHO need to be upstream. If its useful for debug and/or needed on real chipsets (as I believe is the case for the older ones) then a module (and thus kernel command line) option would be sensible yes.
Re: [PATCH 3/3] ipc: Added support for IPC interrupt mode
Quoted 12 lines · One Thousand Gnomes
Quoted 9 lines · On Thu, 14 Nov 2013 09:36:18 -0800 David Cohen <[email protected]>…
Hi Alan,
[snip]
Quoted 4 lines
So I think
1. Pass the informatio upon whether IRQ mode should be used in the platform information and remove all the ifdeffery
Quoted 8 lines
Quoted 3 lines
I will double check with Sathya. But in case polling mode is left for development purpose, make we can create a static variable to set irq mode or not.
If its only for development it doesn't IMHO need to be upstream. If its useful for debug and/or needed on real chipsets (as I believe is the case for the older ones) then a module (and thus kernel command line) option would be sensible yes.
Looks like this patch is keeping poll mode for Lincroft support, since interrupt mode was never tested there. We're sending new version of this patch set soon.
Br, David
v2 cover Enable more Intel Mid platforms on IPC driver
In reply to David CohenHi,
I am resubmitting these patches to enable other Intel Mid platforms on IPC driver.
This change is necessary prior to enable more features for Mid on upstream.
Changes from v1 to v2:
- Fixed bug on patch 1/4: changed PCI_DEVICE to PCI_VDEVICE
- Addressed Alan Cox'c comments:
* Added log message for timeouts
* Remove all #ifdefs from code
Br, David Cohen
---
Kuppuswamy Sathyanarayanan (4):
ipc: Added platform data structure
ipc: Enabled ipc support for additional intel platforms
ipc: Handle error conditions in ipc command
ipc: Added support for IPC interrupt mode
drivers/platform/x86/intel_scu_ipc.c | 117 ++++++++++++++++++++++++++++++----- 1 file changed, 103 insertions(+), 14 deletions(-)
Signature · 1 line
1.8.4.2
PATCH v2 1/4 ipc: Added platform data structure
From: Kuppuswamy Sathyanarayanan <[email protected]>
Since the same ipc driver can be used by many platforms, using macros for defining ipc_base and i2c_base addresses is not a scalable approach. So added a platform data structure to pass this information.
--- drivers/platform/x86/intel_scu_ipc.c | 37 ++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-)
drivers/platform/x86/intel_scu_ipc.c +29 -8
@@ -58,12 +58,29 @@* message handler is called within firmware. */ -#define IPC_BASE_ADDR 0xFF11C000/* IPC1 base register address */ -#define IPC_MAX_ADDR 0x100/* Maximum IPC regisers */ #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 */ + +enum { +SCU_IPC_LINCROFT , +}; + +/* intel scu ipc driver data*/ +struct intel_scu_ipc_pdata_t { +u32 ipc_base; +u32 i2c_base; +u32 ipc_len; +u32 i2c_len; +}; + +static struct intel_scu_ipc_pdata_t intel_scu_ipc_pdata[] = { + [SCU_IPC_LINCROFT ] = { + .ipc_base =0xff11c000 , + .i2c_base =0xff12b000 , + .ipc_len =0x100 , + .i2c_len =0x10 , + }, +};static int ipc_probe (struct pci_dev *dev,const struct pci_device_id *id);static void ipc_remove (struct pci_dev *pdev);
@@ -504,12 +521,16 @@ static irqreturn_t ioc(int irq, void *dev_id)*/ static int ipc_probe (struct pci_dev *dev,const struct pci_device_id *id) { -int err; +int err, pid; +struct intel_scu_ipc_pdata_t *pdata;resource_size_t pci_resource;if (ipcdev.pdev)/* We support only one SCU */ return -EBUSY ; + pid = id->driver_data; + pdata = &intel_scu_ipc_pdata[pid]; + ipcdev.pdev =pci_dev_get (dev); err =pci_enable_device (dev);
@@ -527,11 +548,11 @@ static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id)if (request_irq (dev->irq, ioc,0 ,"intel_scu_ipc" , &ipcdev))return -EBUSY ; - ipcdev.ipc_base =ioremap_nocache (IPC_BASE_ADDR ,IPC_MAX_ADDR ); + ipcdev.ipc_base =ioremap_nocache (pdata->ipc_base, pdata->ipc_len);if (!ipcdev.ipc_base)return -ENOMEM ; - ipcdev.i2c_base =ioremap_nocache (IPC_I2C_BASE ,IPC_I2C_MAX_ADDR ); + ipcdev.i2c_base =ioremap_nocache (pdata->i2c_base, pdata->i2c_len);if (!ipcdev.i2c_base) {iounmap (ipcdev.ipc_base);return -ENOMEM ;
@@ -564,7 +585,7 @@ static void ipc_remove(struct pci_dev *pdev) }static DEFINE_PCI_DEVICE_TABLE (pci_ids) = { - {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,0x082a )}, + {PCI_VDEVICE (INTEL ,0x082a ),SCU_IPC_LINCROFT }, {0 ,} };MODULE_DEVICE_TABLE (pci, pci_ids);
Signature · 1 line
1.8.4.2
PATCH v2 2/4 ipc: Enabled ipc support for additional intel platforms
In reply to David CohenFrom: Kuppuswamy Sathyanarayanan <[email protected]>
Enabled ipc support for penwell, clovertrail & tangier platforms.
--- drivers/platform/x86/intel_scu_ipc.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/platform/x86/intel_scu_ipc.c +24 -0
@@ -63,6 +63,9 @@enum {SCU_IPC_LINCROFT , +SCU_IPC_PENWELL , +SCU_IPC_CLOVERVIEW , +SCU_IPC_TANGIER , };/* intel scu ipc driver data*/
@@ -80,6 +83,24 @@ static struct intel_scu_ipc_pdata_t intel_scu_ipc_pdata[] = { .ipc_len = 0x100, .i2c_len = 0x10, }, + [SCU_IPC_PENWELL] = { + .ipc_base = 0xff11c000, + .i2c_base = 0xff12b000, + .ipc_len = 0x100, + .i2c_len = 0x10, + }, + [SCU_IPC_CLOVERVIEW] = { + .ipc_base = 0xff11c000, + .i2c_base = 0xff12b000, + .ipc_len = 0x100, + .i2c_len = 0x10, + }, + [SCU_IPC_TANGIER] = { + .ipc_base = 0xff009000, + .i2c_base = 0xff00d000, + .ipc_len = 0x100, + .i2c_len = 0x10, + }, };static int ipc_probe (struct pci_dev *dev,const struct pci_device_id *id);
@@ -586,6 +607,9 @@ static void ipc_remove(struct pci_dev *pdev)static DEFINE_PCI_DEVICE_TABLE (pci_ids) = { {PCI_VDEVICE (INTEL ,0x082a ),SCU_IPC_LINCROFT }, + {PCI_VDEVICE (INTEL ,0x080e ),SCU_IPC_PENWELL }, + {PCI_VDEVICE (INTEL ,0x08ea ),SCU_IPC_CLOVERVIEW }, + {PCI_VDEVICE (INTEL ,0x11a0 ),SCU_IPC_TANGIER }, {0 ,} };MODULE_DEVICE_TABLE (pci, pci_ids);
Signature · 1 line
1.8.4.2
PATCH v2 3/4 ipc: Handle error conditions in ipc command
In reply to David CohenFrom: Kuppuswamy Sathyanarayanan <[email protected]>
Handle error conditions in intel_scu_ipc_command() and pwr_reg_rdwr().
--- drivers/platform/x86/intel_scu_ipc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/platform/x86/intel_scu_ipc.c +5 -3
@@ -235,7 +235,7 @@ static int pwr_reg_rdwr(u16 *addr, u8 *data, u32 count, u32 op, u32 id) } err =busy_loop (); -if (id ==IPC_CMD_PCNTRL_R ) {/* Read rbuf */ +if (!err && id ==IPC_CMD_PCNTRL_R ) {/* Read rbuf */ /* Workaround: values are read as 0 without memcpy_fromio */ memcpy_fromio (cbuf, ipcdev.ipc_base +0x90 ,16 );for (nc =0 ; nc < count; nc++)
@@ -465,8 +465,10 @@ int intel_scu_ipc_command(int cmd, int sub, u32 *in, int inlen,ipc_command ((inlen <<16 ) | (sub <<12 ) | cmd); err =busy_loop (); -for (i =0 ; i < outlen; i++) - *out++ =ipc_data_readl (4 * i); +if (!err) { +for (i =0 ; i < outlen; i++) + *out++ =ipc_data_readl (4 * i); + }mutex_unlock (&ipclock);return err;
Signature · 1 line
1.8.4.2
PATCH v2 4/4 ipc: Added support for IPC interrupt mode
In reply to David CohenFrom: Kuppuswamy Sathyanarayanan <[email protected]>
This patch adds support for ipc command interrupt mode. Also added platform data option to select 'irq_mode'
irq_mode = 1: configure the driver to receive IOC interrupt for each successful ipc_command.
irq_mode = 0: makes driver use polling method to
track the command completion status.
--- drivers/platform/x86/intel_scu_ipc.c | 48 +++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-)
drivers/platform/x86/intel_scu_ipc.c +45 -3
@@ -60,6 +60,7 @@#define IPC_WWBUF_SIZE 20/* IPC Write buffer Size */ #define IPC_RWBUF_SIZE 20/* IPC Read buffer Size */ +#define IPC_IOC 0x100/* IPC command register IOC bit */ enum {SCU_IPC_LINCROFT ,
@@ -74,6 +75,7 @@ struct intel_scu_ipc_pdata_t {u32 i2c_base;u32 ipc_len;u32 i2c_len; +u8 irq_mode; };static struct intel_scu_ipc_pdata_t intel_scu_ipc_pdata[] = {
@@ -82,24 +84,28 @@ static struct intel_scu_ipc_pdata_t intel_scu_ipc_pdata[] = { .i2c_base = 0xff12b000, .ipc_len = 0x100, .i2c_len = 0x10, + .irq_mode = 0, }, [SCU_IPC_PENWELL] = { .ipc_base = 0xff11c000, .i2c_base = 0xff12b000, .ipc_len = 0x100, .i2c_len = 0x10, + .irq_mode = 1, }, [SCU_IPC_CLOVERVIEW] = { .ipc_base = 0xff11c000, .i2c_base = 0xff12b000, .ipc_len = 0x100, .i2c_len = 0x10, + .irq_mode = 1, }, [SCU_IPC_TANGIER] = { .ipc_base = 0xff009000, .i2c_base = 0xff00d000, .ipc_len = 0x100, .i2c_len = 0x10, + .irq_mode = 1, }, };
@@ -110,6 +116,8 @@ struct intel_scu_ipc_dev {struct pci_dev *pdev;void __iomem *ipc_base;void __iomem *i2c_base; +struct completion cmd_complete; +u8 irq_mode; };static struct intel_scu_ipc_dev ipcdev;/* Only one for now */
@@ -136,6 +144,10 @@ static DEFINE_MUTEX(ipclock); /* lock used to prevent multiple call to SCU */*/ static inline void ipc_command (u32 cmd)/* Send ipc command */ { +if (ipcdev.irq_mode) { +INIT_COMPLETION (ipcdev.cmd_complete); +writel (cmd |IPC_IOC , ipcdev.ipc_base); + }writel (cmd, ipcdev.ipc_base); }
@@ -194,6 +206,30 @@ static inline int busy_loop(void) /* Wait till scu status is busy */return 0 ; } +/* Wait till ipc ioc interrupt is received or timeout in 3 HZ */ +static inline int ipc_wait_for_interrupt (void ) +{ +int status; + +if (!wait_for_completion_timeout (&ipcdev.cmd_complete,3 *HZ )) { +struct device *dev = &ipcdev.pdev->dev; +dev_err (dev,"IPC timed out\n" ); +return -ETIMEDOUT ; + } + + status =ipc_read_status (); + +if ((status >>1 ) &1 ) +return -EIO ; + +return 0 ; +} + +int intel_scu_ipc_check_status (void ) +{ +return ipcdev.irq_mode ?ipc_wait_for_interrupt () :busy_loop (); +} +/* 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) {
@@ -234,7 +270,7 @@ static int pwr_reg_rdwr(u16 *addr, u8 *data, u32 count, u32 op, u32 id)ipc_command (4 <<16 | id <<12 |0 <<8 | op); } - err =busy_loop (); + err =intel_scu_ipc_check_status ();if (!err && id ==IPC_CMD_PCNTRL_R ) {/* Read rbuf */ /* Workaround: values are read as 0 without memcpy_fromio */ memcpy_fromio (cbuf, ipcdev.ipc_base +0x90 ,16 );
@@ -429,7 +465,7 @@ int intel_scu_ipc_simple_command(int cmd, int sub)return -ENODEV ; }ipc_command (sub <<12 | cmd); - err =busy_loop (); + err =intel_scu_ipc_check_status ();mutex_unlock (&ipclock);return err; }
@@ -463,7 +499,7 @@ int intel_scu_ipc_command(int cmd, int sub, u32 *in, int inlen,ipc_data_writel (*in++,4 * i);ipc_command ((inlen <<16 ) | (sub <<12 ) | cmd); - err =busy_loop (); + err =intel_scu_ipc_check_status ();if (!err) {for (i =0 ; i < outlen; i++)
@@ -531,6 +567,9 @@ EXPORT_SYMBOL(intel_scu_ipc_i2c_cntrl);*/ static irqreturn_t ioc (int irq,void *dev_id) { +if (ipcdev.irq_mode) +complete (&ipcdev.cmd_complete); +return IRQ_HANDLED ; }
@@ -555,6 +594,7 @@ static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id) pdata = &intel_scu_ipc_pdata[pid]; ipcdev.pdev =pci_dev_get (dev); + ipcdev.irq_mode = pdata->irq_mode; err =pci_enable_device (dev);if (err)
@@ -568,6 +608,8 @@ static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id)if (!pci_resource)return -ENOMEM ; +init_completion (&ipcdev.cmd_complete); +if (request_irq (dev->irq, ioc,0 ,"intel_scu_ipc" , &ipcdev))return -EBUSY ;
Signature · 1 line
1.8.4.2
PATCH 1/1 ipc: Added support for IPC interrupt mode
From: Kuppuswamy Sathyanarayanan <[email protected]>
This patch adds support for ipc command interrupt mode. Also added platform data option to select 'irq_mode'
irq_mode = 1: configure the driver to receive IOC interrupt for each successful ipc_command.
irq_mode = 0: makes driver use polling method to
track the command completion status.
---
v2 to v2.1:
- IRQ mode is not stable on Tangier. This new version disables it for such platform.
--- drivers/platform/x86/intel_scu_ipc.c | 48 +++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-)
drivers/platform/x86/intel_scu_ipc.c +45 -3
@@ -60,6 +60,7 @@#define IPC_WWBUF_SIZE 20/* IPC Write buffer Size */ #define IPC_RWBUF_SIZE 20/* IPC Read buffer Size */ +#define IPC_IOC 0x100/* IPC command register IOC bit */ enum {SCU_IPC_LINCROFT ,
@@ -74,6 +75,7 @@ struct intel_scu_ipc_pdata_t {u32 i2c_base;u32 ipc_len;u32 i2c_len; +u8 irq_mode; };static struct intel_scu_ipc_pdata_t intel_scu_ipc_pdata[] = {
@@ -82,24 +84,28 @@ static struct intel_scu_ipc_pdata_t intel_scu_ipc_pdata[] = { .i2c_base = 0xff12b000, .ipc_len = 0x100, .i2c_len = 0x10, + .irq_mode = 0, }, [SCU_IPC_PENWELL] = { .ipc_base = 0xff11c000, .i2c_base = 0xff12b000, .ipc_len = 0x100, .i2c_len = 0x10, + .irq_mode = 1, }, [SCU_IPC_CLOVERVIEW] = { .ipc_base = 0xff11c000, .i2c_base = 0xff12b000, .ipc_len = 0x100, .i2c_len = 0x10, + .irq_mode = 1, }, [SCU_IPC_TANGIER] = { .ipc_base = 0xff009000, .i2c_base = 0xff00d000, .ipc_len = 0x100, .i2c_len = 0x10, + .irq_mode = 0, }, };
@@ -110,6 +116,8 @@ struct intel_scu_ipc_dev {struct pci_dev *pdev;void __iomem *ipc_base;void __iomem *i2c_base; +struct completion cmd_complete; +u8 irq_mode; };static struct intel_scu_ipc_dev ipcdev;/* Only one for now */
@@ -136,6 +144,10 @@ static DEFINE_MUTEX(ipclock); /* lock used to prevent multiple call to SCU */*/ static inline void ipc_command (u32 cmd)/* Send ipc command */ { +if (ipcdev.irq_mode) { +INIT_COMPLETION (ipcdev.cmd_complete); +writel (cmd |IPC_IOC , ipcdev.ipc_base); + }writel (cmd, ipcdev.ipc_base); }
@@ -194,6 +206,30 @@ static inline int busy_loop(void) /* Wait till scu status is busy */return 0 ; } +/* Wait till ipc ioc interrupt is received or timeout in 3 HZ */ +static inline int ipc_wait_for_interrupt (void ) +{ +int status; + +if (!wait_for_completion_timeout (&ipcdev.cmd_complete,3 *HZ )) { +struct device *dev = &ipcdev.pdev->dev; +dev_err (dev,"IPC timed out\n" ); +return -ETIMEDOUT ; + } + + status =ipc_read_status (); + +if ((status >>1 ) &1 ) +return -EIO ; + +return 0 ; +} + +int intel_scu_ipc_check_status (void ) +{ +return ipcdev.irq_mode ?ipc_wait_for_interrupt () :busy_loop (); +} +/* 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) {
@@ -234,7 +270,7 @@ static int pwr_reg_rdwr(u16 *addr, u8 *data, u32 count, u32 op, u32 id)ipc_command (4 <<16 | id <<12 |0 <<8 | op); } - err =busy_loop (); + err =intel_scu_ipc_check_status ();if (!err && id ==IPC_CMD_PCNTRL_R ) {/* Read rbuf */ /* Workaround: values are read as 0 without memcpy_fromio */ memcpy_fromio (cbuf, ipcdev.ipc_base +0x90 ,16 );
@@ -429,7 +465,7 @@ int intel_scu_ipc_simple_command(int cmd, int sub)return -ENODEV ; }ipc_command (sub <<12 | cmd); - err =busy_loop (); + err =intel_scu_ipc_check_status ();mutex_unlock (&ipclock);return err; }
@@ -463,7 +499,7 @@ int intel_scu_ipc_command(int cmd, int sub, u32 *in, int inlen,ipc_data_writel (*in++,4 * i);ipc_command ((inlen <<16 ) | (sub <<12 ) | cmd); - err =busy_loop (); + err =intel_scu_ipc_check_status ();if (!err) {for (i =0 ; i < outlen; i++)
@@ -531,6 +567,9 @@ EXPORT_SYMBOL(intel_scu_ipc_i2c_cntrl);*/ static irqreturn_t ioc (int irq,void *dev_id) { +if (ipcdev.irq_mode) +complete (&ipcdev.cmd_complete); +return IRQ_HANDLED ; }
@@ -555,6 +594,7 @@ static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id) pdata = &intel_scu_ipc_pdata[pid]; ipcdev.pdev =pci_dev_get (dev); + ipcdev.irq_mode = pdata->irq_mode; err =pci_enable_device (dev);if (err)
@@ -568,6 +608,8 @@ static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id)if (!pci_resource)return -ENOMEM ; +init_completion (&ipcdev.cmd_complete); +if (request_irq (dev->irq, ioc,0 ,"intel_scu_ipc" , &ipcdev))return -EBUSY ;
Signature · 1 line
1.8.4.2
PATCH 1/1 ipc: Added support for IPC interrupt mode
This patch adds support for ipc command interrupt mode. Also added platform data option to select 'irq_mode'
irq_mode = 1: configure the driver to receive IOC interrupt for each successful ipc_command.
irq_mode = 0: makes driver use polling method to
track the command completion status.
---
v2.1 to v2.2:
- Changed INIT_COMPLETION to reinit_completion.
--- drivers/platform/x86/intel_scu_ipc.c | 48 +++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-)
drivers/platform/x86/intel_scu_ipc.c +45 -3
@@ -60,6 +60,7 @@#define IPC_WWBUF_SIZE 20/* IPC Write buffer Size */ #define IPC_RWBUF_SIZE 20/* IPC Read buffer Size */ +#define IPC_IOC 0x100/* IPC command register IOC bit */ enum {SCU_IPC_LINCROFT ,
@@ -74,6 +75,7 @@ struct intel_scu_ipc_pdata_t {u32 i2c_base;u32 ipc_len;u32 i2c_len; +u8 irq_mode; };static struct intel_scu_ipc_pdata_t intel_scu_ipc_pdata[] = {
@@ -82,24 +84,28 @@ static struct intel_scu_ipc_pdata_t intel_scu_ipc_pdata[] = { .i2c_base = 0xff12b000, .ipc_len = 0x100, .i2c_len = 0x10, + .irq_mode = 0, }, [SCU_IPC_PENWELL] = { .ipc_base = 0xff11c000, .i2c_base = 0xff12b000, .ipc_len = 0x100, .i2c_len = 0x10, + .irq_mode = 1, }, [SCU_IPC_CLOVERVIEW] = { .ipc_base = 0xff11c000, .i2c_base = 0xff12b000, .ipc_len = 0x100, .i2c_len = 0x10, + .irq_mode = 1, }, [SCU_IPC_TANGIER] = { .ipc_base = 0xff009000, .i2c_base = 0xff00d000, .ipc_len = 0x100, .i2c_len = 0x10, + .irq_mode = 0, }, };
@@ -110,6 +116,8 @@ struct intel_scu_ipc_dev {struct pci_dev *pdev;void __iomem *ipc_base;void __iomem *i2c_base; +struct completion cmd_complete; +u8 irq_mode; };static struct intel_scu_ipc_dev ipcdev;/* Only one for now */
@@ -136,6 +144,10 @@ static DEFINE_MUTEX(ipclock); /* lock used to prevent multiple call to SCU */*/ static inline void ipc_command (u32 cmd)/* Send ipc command */ { +if (ipcdev.irq_mode) { +reinit_completion (&ipcdev.cmd_complete); +writel (cmd |IPC_IOC , ipcdev.ipc_base); + }writel (cmd, ipcdev.ipc_base); }
@@ -194,6 +206,30 @@ static inline int busy_loop(void) /* Wait till scu status is busy */return 0 ; } +/* Wait till ipc ioc interrupt is received or timeout in 3 HZ */ +static inline int ipc_wait_for_interrupt (void ) +{ +int status; + +if (!wait_for_completion_timeout (&ipcdev.cmd_complete,3 *HZ )) { +struct device *dev = &ipcdev.pdev->dev; +dev_err (dev,"IPC timed out\n" ); +return -ETIMEDOUT ; + } + + status =ipc_read_status (); + +if ((status >>1 ) &1 ) +return -EIO ; + +return 0 ; +} + +int intel_scu_ipc_check_status (void ) +{ +return ipcdev.irq_mode ?ipc_wait_for_interrupt () :busy_loop (); +} +/* 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) {
@@ -234,7 +270,7 @@ static int pwr_reg_rdwr(u16 *addr, u8 *data, u32 count, u32 op, u32 id)ipc_command (4 <<16 | id <<12 |0 <<8 | op); } - err =busy_loop (); + err =intel_scu_ipc_check_status ();if (!err && id ==IPC_CMD_PCNTRL_R ) {/* Read rbuf */ /* Workaround: values are read as 0 without memcpy_fromio */ memcpy_fromio (cbuf, ipcdev.ipc_base +0x90 ,16 );
@@ -429,7 +465,7 @@ int intel_scu_ipc_simple_command(int cmd, int sub)return -ENODEV ; }ipc_command (sub <<12 | cmd); - err =busy_loop (); + err =intel_scu_ipc_check_status ();mutex_unlock (&ipclock);return err; }
@@ -463,7 +499,7 @@ int intel_scu_ipc_command(int cmd, int sub, u32 *in, int inlen,ipc_data_writel (*in++,4 * i);ipc_command ((inlen <<16 ) | (sub <<12 ) | cmd); - err =busy_loop (); + err =intel_scu_ipc_check_status ();if (!err) {for (i =0 ; i < outlen; i++)
@@ -531,6 +567,9 @@ EXPORT_SYMBOL(intel_scu_ipc_i2c_cntrl);*/ static irqreturn_t ioc (int irq,void *dev_id) { +if (ipcdev.irq_mode) +complete (&ipcdev.cmd_complete); +return IRQ_HANDLED ; }
@@ -555,6 +594,7 @@ static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id) pdata = &intel_scu_ipc_pdata[pid]; ipcdev.pdev =pci_dev_get (dev); + ipcdev.irq_mode = pdata->irq_mode; err =pci_enable_device (dev);if (err)
@@ -568,6 +608,8 @@ static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id)if (!pci_resource)return -ENOMEM ; +init_completion (&ipcdev.cmd_complete); +if (request_irq (dev->irq, ioc,0 ,"intel_scu_ipc" , &ipcdev))return -EBUSY ;
Signature · 1 line
1.7.9.5
Re: [PATCH v2.2] ipc: Added support for IPC interrupt mode
Quoted 1 line · Kuppuswamy Sathyanarayanan
- Changed
INIT_COMPLETIONtoreinit_completion.
Thanks, I've already folded that fix into the patch and re-pushed.
Signature · 1 line
Matthew Garrett <[email protected]>
Re: [PATCH v2.2] ipc: Added support for IPC interrupt mode
Quoted 5 lines · Matthew Garrett
Quoted 1 line · Kuppuswamy Sathyanarayanan
- Changed
INIT_COMPLETIONtoreinit_completion.Thanks, I've already folded that fix into the patch and re-pushed.
Thanks.
--
Sathyanarayanan Kuppuswamy
Android kernel developer
Applied the set, thanks.
Signature · 1 line
Matthew Garrett <[email protected]>