* [PATCH v1 0/3] platform/x86: intel_mid_powerbtn: Unify workflow
@ 2017-02-02 17:54 Andy Shevchenko
2017-02-02 17:54 ` [PATCH v1 1/3] platform/x86: intel_mid_powerbtn: Unify PBSTATUS access Andy Shevchenko
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Andy Shevchenko @ 2017-02-02 17:54 UTC (permalink / raw)
To: platform-driver-x86, Darren Hart, linux-kernel; +Cc: Andy Shevchenko
Currently there is a mess with PBSTATUS accessors between different
Intel MID platforms. Here is the set to fix it and make driver
eventually neat and almost clean.
Andy Shevchenko (3):
platform/x86: intel_mid_powerbtn: Unify PBSTATUS access
platform/x86: intel_mid_powerbtn: Move comment to where it belongs
platform/x86: intel_mid_powerbtn: Unify IRQ acknowledegment
drivers/platform/x86/intel_mid_powerbtn.c | 80 ++++++++++++-------------------
1 file changed, 30 insertions(+), 50 deletions(-)
--
2.11.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v1 1/3] platform/x86: intel_mid_powerbtn: Unify PBSTATUS access
2017-02-02 17:54 [PATCH v1 0/3] platform/x86: intel_mid_powerbtn: Unify workflow Andy Shevchenko
@ 2017-02-02 17:54 ` Andy Shevchenko
2017-02-02 17:54 ` [PATCH v1 2/3] platform/x86: intel_mid_powerbtn: Move comment to where it belongs Andy Shevchenko
2017-02-02 17:54 ` [PATCH v1 3/3] platform/x86: intel_mid_powerbtn: Unify IRQ acknowledegment Andy Shevchenko
2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2017-02-02 17:54 UTC (permalink / raw)
To: platform-driver-x86, Darren Hart, linux-kernel; +Cc: Andy Shevchenko
The status register on Intel Merrifield can be read in the similar way
it's done for previous MID platforms. Unify access to PBSTATUS register
via SCU IPC.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/platform/x86/intel_mid_powerbtn.c | 41 ++++++++++---------------------
1 file changed, 13 insertions(+), 28 deletions(-)
diff --git a/drivers/platform/x86/intel_mid_powerbtn.c b/drivers/platform/x86/intel_mid_powerbtn.c
index 1d30b3549748..594d503ca6fe 100644
--- a/drivers/platform/x86/intel_mid_powerbtn.c
+++ b/drivers/platform/x86/intel_mid_powerbtn.c
@@ -40,37 +40,37 @@
#define MSIC_PWRBTNM (1 << 0)
/* Intel Tangier */
-#define MRFLD_PBSTAT_ADDR 0xfffff61a
-#define MRFLD_PB_LEVEL (1 << 4) /* 1 - release, 0 - press */
+#define BCOVE_PB_LEVEL (1 << 4) /* 1 - release, 0 - press */
/* Basin Cove PMIC */
#define BCOVE_PBIRQ 0x02
#define BCOVE_IRQLVL1MSK 0x0c
#define BCOVE_PBIRQMASK 0x0d
+#define BCOVE_PBSTATUS 0x27
struct mid_pb_ddata {
struct device *dev;
- void __iomem *reg;
int irq;
struct input_dev *input;
- int (*pbstat)(struct mid_pb_ddata *ddata, int *value);
+ unsigned short pbstat_addr;
+ u8 pbstat_mask;
int (*ack)(struct mid_pb_ddata *ddata);
int (*setup)(struct mid_pb_ddata *ddata);
};
-static int mfld_pbstat(struct mid_pb_ddata *ddata, int *value)
+static int mid_pbstat(struct mid_pb_ddata *ddata, int *value)
{
struct input_dev *input = ddata->input;
int ret;
u8 pbstat;
- ret = intel_msic_reg_read(INTEL_MSIC_PBSTATUS, &pbstat);
+ ret = intel_msic_reg_read(ddata->pbstat_addr, &pbstat);
if (ret)
return ret;
dev_dbg(input->dev.parent, "PB_INT status= %d\n", pbstat);
- *value = !(pbstat & MSIC_PB_LEVEL);
+ *value = !(pbstat & ddata->pbstat_mask);
return 0;
}
@@ -89,19 +89,6 @@ static int mfld_ack(struct mid_pb_ddata *ddata)
return intel_msic_reg_update(INTEL_MSIC_IRQLVL1MSK, 0, MSIC_PWRBTNM);
}
-static int mrfld_pbstat(struct mid_pb_ddata *ddata, int *value)
-{
- struct input_dev *input = ddata->input;
- u8 pbstat;
-
- pbstat = readb(ddata->reg);
-
- dev_dbg(input->dev.parent, "PB_INT status= %d\n", pbstat);
-
- *value = !(pbstat & MRFLD_PB_LEVEL);
- return 0;
-}
-
static int mrfld_ack(struct mid_pb_ddata *ddata)
{
return intel_scu_ipc_update_register(BCOVE_IRQLVL1MSK, 0, MSIC_PWRBTNM);
@@ -109,10 +96,6 @@ static int mrfld_ack(struct mid_pb_ddata *ddata)
static int mrfld_setup(struct mid_pb_ddata *ddata)
{
- ddata->reg = devm_ioremap_nocache(ddata->dev, MRFLD_PBSTAT_ADDR, 1);
- if (!ddata->reg)
- return -ENOMEM;
-
/* Unmask the PBIRQ and MPBIRQ on Tangier */
intel_scu_ipc_update_register(BCOVE_PBIRQ, 0, MSIC_PWRBTNM);
intel_scu_ipc_update_register(BCOVE_PBIRQMASK, 0, MSIC_PWRBTNM);
@@ -124,10 +107,10 @@ static irqreturn_t mid_pb_isr(int irq, void *dev_id)
{
struct mid_pb_ddata *ddata = dev_id;
struct input_dev *input = ddata->input;
- int value;
+ int value = 0;
int ret;
- ret = ddata->pbstat(ddata, &value);
+ ret = mid_pbstat(ddata, &value);
if (ret < 0) {
dev_err(input->dev.parent,
"Read error %d while reading MSIC_PB_STATUS\n", ret);
@@ -141,12 +124,14 @@ static irqreturn_t mid_pb_isr(int irq, void *dev_id)
}
static struct mid_pb_ddata mfld_ddata = {
- .pbstat = mfld_pbstat,
+ .pbstat_addr = INTEL_MSIC_PBSTATUS,
+ .pbstat_mask = MSIC_PB_LEVEL,
.ack = mfld_ack,
};
static struct mid_pb_ddata mrfld_ddata = {
- .pbstat = mrfld_pbstat,
+ .pbstat_addr = BCOVE_PBSTATUS,
+ .pbstat_mask = BCOVE_PB_LEVEL,
.ack = mrfld_ack,
.setup = mrfld_setup,
};
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v1 2/3] platform/x86: intel_mid_powerbtn: Move comment to where it belongs
2017-02-02 17:54 [PATCH v1 0/3] platform/x86: intel_mid_powerbtn: Unify workflow Andy Shevchenko
2017-02-02 17:54 ` [PATCH v1 1/3] platform/x86: intel_mid_powerbtn: Unify PBSTATUS access Andy Shevchenko
@ 2017-02-02 17:54 ` Andy Shevchenko
2017-02-02 17:54 ` [PATCH v1 3/3] platform/x86: intel_mid_powerbtn: Unify IRQ acknowledegment Andy Shevchenko
2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2017-02-02 17:54 UTC (permalink / raw)
To: platform-driver-x86, Darren Hart, linux-kernel; +Cc: Andy Shevchenko
The comments is about initial interrupt acknowledgment only. So, move it
back to where it belongs.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/platform/x86/intel_mid_powerbtn.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/platform/x86/intel_mid_powerbtn.c b/drivers/platform/x86/intel_mid_powerbtn.c
index 594d503ca6fe..de40c71883f8 100644
--- a/drivers/platform/x86/intel_mid_powerbtn.c
+++ b/drivers/platform/x86/intel_mid_powerbtn.c
@@ -76,16 +76,6 @@ static int mid_pbstat(struct mid_pb_ddata *ddata, int *value)
static int mfld_ack(struct mid_pb_ddata *ddata)
{
- /*
- * SCU firmware might send power button interrupts to IA core before
- * kernel boots and doesn't get EOI from IA core. The first bit of
- * MSIC reg 0x21 is kept masked, and SCU firmware doesn't send new
- * power interrupt to Android kernel. Unmask the bit when probing
- * power button in kernel.
- * There is a very narrow race between irq handler and power button
- * initialization. The race happens rarely. So we needn't worry
- * about it.
- */
return intel_msic_reg_update(INTEL_MSIC_IRQLVL1MSK, 0, MSIC_PWRBTNM);
}
@@ -202,6 +192,16 @@ static int mid_pb_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, ddata);
+ /*
+ * SCU firmware might send power button interrupts to IA core before
+ * kernel boots and doesn't get EOI from IA core. The first bit of
+ * MSIC reg 0x21 is kept masked, and SCU firmware doesn't send new
+ * power interrupt to Android kernel. Unmask the bit when probing
+ * power button in kernel.
+ * There is a very narrow race between irq handler and power button
+ * initialization. The race happens rarely. So we needn't worry
+ * about it.
+ */
error = ddata->ack(ddata);
if (error) {
dev_err(&pdev->dev,
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v1 3/3] platform/x86: intel_mid_powerbtn: Unify IRQ acknowledegment
2017-02-02 17:54 [PATCH v1 0/3] platform/x86: intel_mid_powerbtn: Unify workflow Andy Shevchenko
2017-02-02 17:54 ` [PATCH v1 1/3] platform/x86: intel_mid_powerbtn: Unify PBSTATUS access Andy Shevchenko
2017-02-02 17:54 ` [PATCH v1 2/3] platform/x86: intel_mid_powerbtn: Move comment to where it belongs Andy Shevchenko
@ 2017-02-02 17:54 ` Andy Shevchenko
2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2017-02-02 17:54 UTC (permalink / raw)
To: platform-driver-x86, Darren Hart, linux-kernel; +Cc: Andy Shevchenko
The IRQ on Intel Merrifield can be acknowledged in the similar way it's
done for previous MID platforms. Unify acknowledgement via SCU IPC.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/platform/x86/intel_mid_powerbtn.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/drivers/platform/x86/intel_mid_powerbtn.c b/drivers/platform/x86/intel_mid_powerbtn.c
index de40c71883f8..38844f765345 100644
--- a/drivers/platform/x86/intel_mid_powerbtn.c
+++ b/drivers/platform/x86/intel_mid_powerbtn.c
@@ -52,9 +52,9 @@ struct mid_pb_ddata {
struct device *dev;
int irq;
struct input_dev *input;
+ unsigned short mirqlvl1_addr;
unsigned short pbstat_addr;
u8 pbstat_mask;
- int (*ack)(struct mid_pb_ddata *ddata);
int (*setup)(struct mid_pb_ddata *ddata);
};
@@ -74,14 +74,9 @@ static int mid_pbstat(struct mid_pb_ddata *ddata, int *value)
return 0;
}
-static int mfld_ack(struct mid_pb_ddata *ddata)
+static int mid_irq_ack(struct mid_pb_ddata *ddata)
{
- return intel_msic_reg_update(INTEL_MSIC_IRQLVL1MSK, 0, MSIC_PWRBTNM);
-}
-
-static int mrfld_ack(struct mid_pb_ddata *ddata)
-{
- return intel_scu_ipc_update_register(BCOVE_IRQLVL1MSK, 0, MSIC_PWRBTNM);
+ return intel_msic_reg_update(ddata->mirqlvl1_addr, 0, MSIC_PWRBTNM);
}
static int mrfld_setup(struct mid_pb_ddata *ddata)
@@ -109,20 +104,20 @@ static irqreturn_t mid_pb_isr(int irq, void *dev_id)
input_sync(input);
}
- ddata->ack(ddata);
+ mid_irq_ack(ddata);
return IRQ_HANDLED;
}
static struct mid_pb_ddata mfld_ddata = {
+ .mirqlvl1_addr = INTEL_MSIC_IRQLVL1MSK,
.pbstat_addr = INTEL_MSIC_PBSTATUS,
.pbstat_mask = MSIC_PB_LEVEL,
- .ack = mfld_ack,
};
static struct mid_pb_ddata mrfld_ddata = {
+ .mirqlvl1_addr = BCOVE_IRQLVL1MSK,
.pbstat_addr = BCOVE_PBSTATUS,
.pbstat_mask = BCOVE_PB_LEVEL,
- .ack = mrfld_ack,
.setup = mrfld_setup,
};
@@ -202,7 +197,7 @@ static int mid_pb_probe(struct platform_device *pdev)
* initialization. The race happens rarely. So we needn't worry
* about it.
*/
- error = ddata->ack(ddata);
+ error = mid_irq_ack(ddata);
if (error) {
dev_err(&pdev->dev,
"Unable to clear power button interrupt, error: %d\n",
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-02-02 17:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-02 17:54 [PATCH v1 0/3] platform/x86: intel_mid_powerbtn: Unify workflow Andy Shevchenko
2017-02-02 17:54 ` [PATCH v1 1/3] platform/x86: intel_mid_powerbtn: Unify PBSTATUS access Andy Shevchenko
2017-02-02 17:54 ` [PATCH v1 2/3] platform/x86: intel_mid_powerbtn: Move comment to where it belongs Andy Shevchenko
2017-02-02 17:54 ` [PATCH v1 3/3] platform/x86: intel_mid_powerbtn: Unify IRQ acknowledegment Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).