* [PATCH v2 00/14] Update 88pm860x and max8925 MFD driver
[not found] <2011041801>
@ 2011-04-18 14:03 ` Haojian Zhuang
2011-04-18 14:03 ` [PATCH 01/14] input: touchscreen: use polling mode in 88pm860x Haojian Zhuang
` (13 subsequent siblings)
14 siblings, 0 replies; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-18 14:03 UTC (permalink / raw)
To: sameo, haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo,
johnpol, cbou, dwmw2, lrg, broonie
Changelog:
v2:
1. Fix the calculation issue on time in touch driver of 88pm860x.
2. Always checking return code in open() of touch driver of 88pm860x.
3. Avoid to check constraint name in regulator driver. Check
driver_data instead.
^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH 01/14] input: touchscreen: use polling mode in 88pm860x
[not found] <2011041801>
2011-04-18 14:03 ` [PATCH v2 00/14] Update 88pm860x and max8925 MFD driver Haojian Zhuang
@ 2011-04-18 14:03 ` Haojian Zhuang
2011-04-18 14:03 ` [PATCH 02/14] input: touchscreen: move initialization " Haojian Zhuang
` (12 subsequent siblings)
14 siblings, 0 replies; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-18 14:03 UTC (permalink / raw)
To: sameo, haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo,
johnpol, cbou, dwmw2, lrg, broonie
Cc: Haojian Zhuang
Measuring point on touchscreen with IRQ mode can only monitor pen-down
event. If finger is moving on touchscreen, it can't be monitored by
IRQ pen-down event. So switch to polling mode after pen-down event.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/touchscreen/88pm860x-ts.c | 79 ++++++++++++++++++++++++------
1 files changed, 63 insertions(+), 16 deletions(-)
diff --git a/drivers/input/touchscreen/88pm860x-ts.c b/drivers/input/touchscreen/88pm860x-ts.c
index b3aebc2..dbb3435 100644
--- a/drivers/input/touchscreen/88pm860x-ts.c
+++ b/drivers/input/touchscreen/88pm860x-ts.c
@@ -12,13 +12,25 @@
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/i2c.h>
+#include <linux/slab.h>
#include <linux/input.h>
#include <linux/mfd/88pm860x.h>
-#include <linux/slab.h>
#define MEAS_LEN (8)
#define ACCURATE_BIT (12)
+/*
+ * While 32KHz hardware timer is used for scheduler, we always assign HZ
+ * to 128. It means that 1 tick costs 7.8msec.
+ */
+#define MEASURE_INTERVAL_MS (7)
+
+/* debounce register */
+#define DEBOUNCE (0x0A)
+
+#define PD_DEBOUNCE_0MSEC (0)
+#define PD_DEBOUNCE_MASK (3)
+
/* touch register */
#define MEAS_EN3 (0x52)
@@ -39,22 +51,27 @@
#define MEAS_TSIZ2_EN (1 << 7)
struct pm860x_touch {
- struct input_dev *idev;
- struct i2c_client *i2c;
- struct pm860x_chip *chip;
- int irq;
- int res_x; /* resistor of Xplate */
+ struct input_dev *idev;
+ struct i2c_client *i2c;
+ struct pm860x_chip *chip;
+ struct delayed_work poll_work;
+ struct mutex lock;
+
+ int irq;
+ int res_x; /* resistor of Xplate */
};
-static irqreturn_t pm860x_touch_handler(int irq, void *data)
+static void pm860x_poll_work(struct work_struct *work)
{
- struct pm860x_touch *touch = data;
+ struct pm860x_touch *touch = container_of(work, struct pm860x_touch,
+ poll_work.work);
struct pm860x_chip *chip = touch->chip;
+ int x, y, z1, z2, rt = 0;
+ int ret, pen_down, interval;
unsigned char buf[MEAS_LEN];
- int x, y, pen_down;
- int z1, z2, rt = 0;
- int ret;
+ struct timeval start, end;
+ do_gettimeofday(&start);
ret = pm860x_bulk_read(touch->i2c, MEAS_TSIX_1, MEAS_LEN, buf);
if (ret < 0)
goto out;
@@ -77,14 +94,39 @@ static irqreturn_t pm860x_touch_handler(int irq, void *data)
input_report_abs(touch->idev, ABS_PRESSURE, rt);
input_report_key(touch->idev, BTN_TOUCH, 1);
dev_dbg(chip->dev, "pen down at [%d, %d].\n", x, y);
+
+ do_gettimeofday(&end);
+ interval = ((end.tv_sec - start.tv_sec) * 1000000 +
+ (end.tv_usec - start.tv_usec)) / 1000;
+ interval = (interval < MEASURE_INTERVAL_MS)
+ ? (MEASURE_INTERVAL_MS - interval) : 0;
+ schedule_delayed_work(&touch->poll_work,
+ msecs_to_jiffies(interval));
} else {
input_report_abs(touch->idev, ABS_PRESSURE, 0);
input_report_key(touch->idev, BTN_TOUCH, 0);
dev_dbg(chip->dev, "pen release\n");
+ mutex_unlock(&touch->lock);
}
input_sync(touch->idev);
out:
+ return;
+}
+
+static irqreturn_t pm860x_touch_handler(int irq, void *data)
+{
+ struct pm860x_touch *touch = data;
+ int ret;
+
+ ret = pm860x_reg_read(touch->i2c, PM8607_STATUS_1);
+ dev_dbg(touch->chip->dev, "pen status:%d\n", (ret & PM8607_STATUS_PEN)
+ ? 1 : 0);
+ if ((ret & PM8607_STATUS_PEN) == 0)
+ return IRQ_HANDLED;
+
+ mutex_lock(&touch->lock);
+ pm860x_poll_work(&touch->poll_work.work);
return IRQ_HANDLED;
}
@@ -93,12 +135,14 @@ static int pm860x_touch_open(struct input_dev *dev)
struct pm860x_touch *touch = input_get_drvdata(dev);
int data, ret;
+ /* set debounce time with 0ms */
+ ret = pm860x_set_bits(touch->i2c, DEBOUNCE, PD_DEBOUNCE_MASK,
+ PD_DEBOUNCE_0MSEC);
+ if (ret < 0)
+ goto out;
data = MEAS_PD_EN | MEAS_TSIX_EN | MEAS_TSIY_EN
| MEAS_TSIZ1_EN | MEAS_TSIZ2_EN;
ret = pm860x_set_bits(touch->i2c, MEAS_EN3, data, data);
- if (ret < 0)
- goto out;
- return 0;
out:
return ret;
}
@@ -152,16 +196,17 @@ static int __devinit pm860x_touch_probe(struct platform_device *pdev)
}
touch->idev->name = "88pm860x-touch";
- touch->idev->phys = "88pm860x/input0";
+ touch->idev->phys = "88pm860x/input1";
touch->idev->id.bustype = BUS_I2C;
touch->idev->dev.parent = &pdev->dev;
touch->idev->open = pm860x_touch_open;
touch->idev->close = pm860x_touch_close;
touch->chip = chip;
touch->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion;
- touch->irq = irq + chip->irq_base;
+ touch->irq = irq;
touch->res_x = pdata->res_x;
input_set_drvdata(touch->idev, touch);
+ mutex_init(&touch->lock);
ret = request_threaded_irq(touch->irq, NULL, pm860x_touch_handler,
IRQF_ONESHOT, "touch", touch);
@@ -188,6 +233,7 @@ static int __devinit pm860x_touch_probe(struct platform_device *pdev)
}
platform_set_drvdata(pdev, touch);
+ INIT_DELAYED_WORK(&touch->poll_work, pm860x_poll_work);
return 0;
out_rg:
free_irq(touch->irq, touch);
@@ -202,6 +248,7 @@ static int __devexit pm860x_touch_remove(struct platform_device *pdev)
{
struct pm860x_touch *touch = platform_get_drvdata(pdev);
+ flush_scheduled_work();
input_unregister_device(touch->idev);
free_irq(touch->irq, touch);
platform_set_drvdata(pdev, NULL);
--
1.5.6.5
^ permalink raw reply related [flat|nested] 52+ messages in thread
* [PATCH 02/14] input: touchscreen: move initialization in 88pm860x
[not found] <2011041801>
2011-04-18 14:03 ` [PATCH v2 00/14] Update 88pm860x and max8925 MFD driver Haojian Zhuang
2011-04-18 14:03 ` [PATCH 01/14] input: touchscreen: use polling mode in 88pm860x Haojian Zhuang
@ 2011-04-18 14:03 ` Haojian Zhuang
2011-04-26 8:57 ` Samuel Ortiz
2011-04-18 14:04 ` [PATCH 03/14] rtc: add 88pm860x rtc Haojian Zhuang
` (11 subsequent siblings)
14 siblings, 1 reply; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-18 14:03 UTC (permalink / raw)
To: sameo, haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo,
johnpol, cbou, dwmw2, lrg, broonie
Cc: Haojian Zhuang
Move the GPADC initialization code from mfd driver to touch driver.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/touchscreen/88pm860x-ts.c | 44 +++++++++++++++++++++-----
drivers/mfd/88pm860x-core.c | 51 -------------------------------
2 files changed, 35 insertions(+), 60 deletions(-)
diff --git a/drivers/input/touchscreen/88pm860x-ts.c b/drivers/input/touchscreen/88pm860x-ts.c
index dbb3435..8ae2856 100644
--- a/drivers/input/touchscreen/88pm860x-ts.c
+++ b/drivers/input/touchscreen/88pm860x-ts.c
@@ -14,6 +14,7 @@
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/input.h>
+#include <linux/mfd/core.h>
#include <linux/mfd/88pm860x.h>
#define MEAS_LEN (8)
@@ -157,11 +158,40 @@ static void pm860x_touch_close(struct input_dev *dev)
pm860x_set_bits(touch->i2c, MEAS_EN3, data, 0);
}
+static void __devinit pm860x_gpadc_init(struct i2c_client *i2c,
+ struct pm860x_touch_pdata *pdata)
+{
+ int data;
+
+ /* set GPADC MISC1 register */
+ data = 0;
+ data |= (pdata->gpadc_prebias << 1) & PM8607_GPADC_PREBIAS_MASK;
+ data |= (pdata->slot_cycle << 3) & PM8607_GPADC_SLOT_CYCLE_MASK;
+ data |= (pdata->off_scale << 5) & PM8607_GPADC_OFF_SCALE_MASK;
+ data |= (pdata->sw_cal << 7) & PM8607_GPADC_SW_CAL_MASK;
+ if (data)
+ pm860x_reg_write(i2c, PM8607_GPADC_MISC1, data);
+
+ /* set tsi prebias time */
+ if (pdata->tsi_prebias) {
+ data = pdata->tsi_prebias;
+ pm860x_reg_write(i2c, PM8607_TSI_PREBIAS, data);
+ }
+
+ /* set prebias & prechg time of pen detect */
+ data = 0;
+ data |= pdata->pen_prebias & PM8607_PD_PREBIAS_MASK;
+ data |= (pdata->pen_prechg << 5) & PM8607_PD_PRECHG_MASK;
+ if (data)
+ pm860x_reg_write(i2c, PM8607_PD_PREBIAS, data);
+
+ pm860x_set_bits(i2c, PM8607_GPADC_MISC1,
+ PM8607_GPADC_EN, PM8607_GPADC_EN);
+}
+
static int __devinit pm860x_touch_probe(struct platform_device *pdev)
{
struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
- struct pm860x_platform_data *pm860x_pdata = \
- pdev->dev.parent->platform_data;
struct pm860x_touch_pdata *pdata = NULL;
struct pm860x_touch *touch;
int irq, ret;
@@ -172,13 +202,8 @@ static int __devinit pm860x_touch_probe(struct platform_device *pdev)
return -EINVAL;
}
- if (!pm860x_pdata) {
- dev_err(&pdev->dev, "platform data is missing\n");
- return -EINVAL;
- }
-
- pdata = pm860x_pdata->touch;
- if (!pdata) {
+ pdata = pdev->dev.platform_data;
+ if (pdata == NULL) {
dev_err(&pdev->dev, "touchscreen data is missing\n");
return -EINVAL;
}
@@ -232,6 +257,7 @@ static int __devinit pm860x_touch_probe(struct platform_device *pdev)
goto out_rg;
}
+ pm860x_gpadc_init(touch->i2c, pdata);
platform_set_drvdata(pdev, touch);
INIT_DELAYED_WORK(&touch->poll_work, pm860x_poll_work);
return 0;
diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c
index 801aff7..b03cdd3 100644
--- a/drivers/mfd/88pm860x-core.c
+++ b/drivers/mfd/88pm860x-core.c
@@ -362,53 +362,6 @@ static struct irq_chip pm860x_irq_chip = {
.irq_disable = pm860x_irq_disable,
};
-static int __devinit device_gpadc_init(struct pm860x_chip *chip,
- struct pm860x_platform_data *pdata)
-{
- struct i2c_client *i2c = (chip->id == CHIP_PM8607) ? chip->client \
- : chip->companion;
- int data;
- int ret;
-
- /* initialize GPADC without activating it */
-
- if (!pdata || !pdata->touch)
- return -EINVAL;
-
- /* set GPADC MISC1 register */
- data = 0;
- data |= (pdata->touch->gpadc_prebias << 1) & PM8607_GPADC_PREBIAS_MASK;
- data |= (pdata->touch->slot_cycle << 3) & PM8607_GPADC_SLOT_CYCLE_MASK;
- data |= (pdata->touch->off_scale << 5) & PM8607_GPADC_OFF_SCALE_MASK;
- data |= (pdata->touch->sw_cal << 7) & PM8607_GPADC_SW_CAL_MASK;
- if (data) {
- ret = pm860x_reg_write(i2c, PM8607_GPADC_MISC1, data);
- if (ret < 0)
- goto out;
- }
- /* set tsi prebias time */
- if (pdata->touch->tsi_prebias) {
- data = pdata->touch->tsi_prebias;
- ret = pm860x_reg_write(i2c, PM8607_TSI_PREBIAS, data);
- if (ret < 0)
- goto out;
- }
- /* set prebias & prechg time of pen detect */
- data = 0;
- data |= pdata->touch->pen_prebias & PM8607_PD_PREBIAS_MASK;
- data |= (pdata->touch->pen_prechg << 5) & PM8607_PD_PRECHG_MASK;
- if (data) {
- ret = pm860x_reg_write(i2c, PM8607_PD_PREBIAS, data);
- if (ret < 0)
- goto out;
- }
-
- ret = pm860x_set_bits(i2c, PM8607_GPADC_MISC1,
- PM8607_GPADC_EN, PM8607_GPADC_EN);
-out:
- return ret;
-}
-
static int __devinit device_irq_init(struct pm860x_chip *chip,
struct pm860x_platform_data *pdata)
{
@@ -761,10 +714,6 @@ static void __devinit device_8607_init(struct pm860x_chip *chip,
goto out;
}
- ret = device_gpadc_init(chip, pdata);
- if (ret < 0)
- goto out;
-
ret = device_irq_init(chip, pdata);
if (ret < 0)
goto out;
--
1.5.6.5
^ permalink raw reply related [flat|nested] 52+ messages in thread
* [PATCH 03/14] rtc: add 88pm860x rtc
[not found] <2011041801>
` (2 preceding siblings ...)
2011-04-18 14:03 ` [PATCH 02/14] input: touchscreen: move initialization " Haojian Zhuang
@ 2011-04-18 14:04 ` Haojian Zhuang
2011-04-26 8:58 ` Samuel Ortiz
2011-04-18 14:04 ` [PATCH 04/14] input: set the long press detection in 88pm860x onkey Haojian Zhuang
` (10 subsequent siblings)
14 siblings, 1 reply; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-18 14:04 UTC (permalink / raw)
To: sameo, haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo,
johnpol, cbou, dwmw2, lrg, broonie
Cc: Haojian Zhuang
Support RTC component in 88PM860x. Also support synchronize time from
88PM860x RTC to another RTC device. It should be implemented in
sync callback API.
While 88PM860x RTC is enabled, it can do RTC calibration to gurantee
enough power is supplied on VRTC domain of 88PM860x.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
---
drivers/mfd/88pm860x-core.c | 31 +++
drivers/rtc/Kconfig | 10 +
drivers/rtc/Makefile | 1 +
drivers/rtc/rtc-88pm860x.c | 426 ++++++++++++++++++++++++++++++++++++++++++
include/linux/mfd/88pm860x.h | 6 +
5 files changed, 474 insertions(+), 0 deletions(-)
create mode 100644 drivers/rtc/rtc-88pm860x.c
diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c
index b03cdd3..f114ec7 100644
--- a/drivers/mfd/88pm860x-core.c
+++ b/drivers/mfd/88pm860x-core.c
@@ -57,6 +57,10 @@ static struct resource regulator_resources[] __initdata = {
{PM8607_ID_LDO15, PM8607_ID_LDO15, "ldo-15", IORESOURCE_IO,},
};
+static struct resource rtc_resources[] __devinitdata = {
+ {PM8607_IRQ_RTC, PM8607_IRQ_RTC, "rtc", IORESOURCE_IRQ,},
+};
+
static struct resource touch_resources[] __initdata = {
{PM8607_IRQ_PEN, PM8607_IRQ_PEN, "touch", IORESOURCE_IRQ,},
};
@@ -126,6 +130,10 @@ static struct mfd_cell regulator_devs[] __initdata = {
{"88pm860x-regulator", 17,},
};
+static struct mfd_cell rtc_devs[] = {
+ {"88pm860x-rtc", -1,},
+};
+
static struct mfd_cell touch_devs[] __initdata = {
{"88pm860x-touch", -1,},
};
@@ -148,6 +156,7 @@ static struct pm860x_led_pdata led_pdata[ARRAY_SIZE(led_devs)];
static struct regulator_init_data regulator_pdata[ARRAY_SIZE(regulator_devs)];
static struct pm860x_touch_pdata touch_pdata;
static struct pm860x_power_pdata power_pdata;
+static struct pm860x_rtc_pdata rtc_pdata;
struct pm860x_irq_data {
int reg;
@@ -588,6 +597,27 @@ out:
return;
}
+static void __devinit device_rtc_init(struct pm860x_chip *chip,
+ struct i2c_client *i2c,
+ struct pm860x_platform_data *pdata)
+{
+ int ret;
+
+ if ((pdata == NULL) || (pdata->rtc == NULL))
+ return;
+
+ memcpy(&rtc_pdata, pdata->rtc, sizeof(struct pm860x_rtc_pdata));
+ rtc_devs[0].platform_data = &rtc_pdata;
+ rtc_devs[0].pdata_size = sizeof(rtc_pdata);
+ rtc_devs[0].num_resources = ARRAY_SIZE(rtc_resources);
+ rtc_devs[0].resources = &rtc_resources[0];
+ ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0],
+ ARRAY_SIZE(rtc_devs), &rtc_resources[0],
+ chip->irq_base);
+ if (ret < 0)
+ dev_err(chip->dev, "Failed to add rtc subdev\n");
+}
+
static void __devinit device_touch_init(struct pm860x_chip *chip,
struct i2c_client *i2c,
struct pm860x_platform_data *pdata)
@@ -719,6 +749,7 @@ static void __devinit device_8607_init(struct pm860x_chip *chip,
goto out;
device_regulator_init(chip, i2c, pdata);
+ device_rtc_init(chip, i2c, pdata);
device_onkey_init(chip, i2c, pdata);
device_touch_init(chip, i2c, pdata);
device_power_init(chip, i2c, pdata);
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index e187887..286f51e 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -128,6 +128,16 @@ comment "I2C RTC drivers"
if I2C
+config RTC_DRV_88PM860X
+ tristate "Marvell 88PM860x"
+ depends on RTC_CLASS && I2C && MFD_88PM860X
+ help
+ If you say yes here you get support for RTC function in Marvell
+ 88PM860x chips.
+
+ This driver can also be built as a module. If so, the module
+ will be called rtc-88pm860x.
+
config RTC_DRV_DS1307
tristate "Dallas/Maxim DS1307/37/38/39/40, ST M41T00, EPSON RX-8025"
help
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index ca91c3c..e3d6fb0 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -15,6 +15,7 @@ rtc-core-$(CONFIG_RTC_INTF_SYSFS) += rtc-sysfs.o
# Keep the list ordered.
+obj-$(CONFIG_RTC_DRV_88PM860X) += rtc-88pm860x.o
obj-$(CONFIG_RTC_DRV_AB3100) += rtc-ab3100.o
obj-$(CONFIG_RTC_DRV_AB8500) += rtc-ab8500.o
obj-$(CONFIG_RTC_DRV_AT32AP700X)+= rtc-at32ap700x.o
diff --git a/drivers/rtc/rtc-88pm860x.c b/drivers/rtc/rtc-88pm860x.c
new file mode 100644
index 0000000..864e6c4
--- /dev/null
+++ b/drivers/rtc/rtc-88pm860x.c
@@ -0,0 +1,426 @@
+/*
+ * Real Time Clock driver for Marvell 88PM860x PMIC
+ *
+ * Copyright (c) 2010 Marvell International Ltd.
+ * Author: Haojian Zhuang <haojian.zhuang@marvell.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/mutex.h>
+#include <linux/rtc.h>
+#include <linux/delay.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/88pm860x.h>
+
+#define VRTC_CALIBRATION
+
+struct pm860x_rtc_info {
+ struct pm860x_chip *chip;
+ struct i2c_client *i2c;
+ struct rtc_device *rtc_dev;
+ struct device *dev;
+ struct delayed_work calib_work;
+
+ int irq;
+ int vrtc;
+ int (*sync)(unsigned int ticks);
+};
+
+#define REG_VRTC_MEAS1 0x7D
+
+#define REG0_ADDR 0xB0
+#define REG1_ADDR 0xB2
+#define REG2_ADDR 0xB4
+#define REG3_ADDR 0xB6
+
+#define REG0_DATA 0xB1
+#define REG1_DATA 0xB3
+#define REG2_DATA 0xB5
+#define REG3_DATA 0xB7
+
+/* bit definitions of Measurement Enable Register 2 (0x51) */
+#define MEAS2_VRTC (1 << 0)
+
+/* bit definitions of RTC Register 1 (0xA0) */
+#define ALARM_EN (1 << 3)
+#define ALARM_WAKEUP (1 << 4)
+#define ALARM (1 << 5)
+#define RTC1_USE_XO (1 << 7)
+
+#define VRTC_CALIB_INTERVAL (HZ * 60 * 10) /* 10 minutes */
+
+static irqreturn_t rtc_update_handler(int irq, void *data)
+{
+ struct pm860x_rtc_info *info = (struct pm860x_rtc_info *)data;
+ int mask;
+
+ mask = ALARM | ALARM_WAKEUP;
+ pm860x_set_bits(info->i2c, PM8607_RTC1, mask | ALARM_EN, mask);
+ rtc_update_irq(info->rtc_dev, 1, RTC_AF);
+ return IRQ_HANDLED;
+}
+
+static int pm860x_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
+{
+ struct pm860x_rtc_info *info = dev_get_drvdata(dev);
+
+ if (enabled)
+ pm860x_set_bits(info->i2c, PM8607_RTC1, ALARM, ALARM);
+ else
+ pm860x_set_bits(info->i2c, PM8607_RTC1, ALARM, 0);
+ return 0;
+}
+
+/*
+ * Calculate the next alarm time given the requested alarm time mask
+ * and the current time.
+ */
+static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now,
+ struct rtc_time *alrm)
+{
+ unsigned long next_time;
+ unsigned long now_time;
+
+ next->tm_year = now->tm_year;
+ next->tm_mon = now->tm_mon;
+ next->tm_mday = now->tm_mday;
+ next->tm_hour = alrm->tm_hour;
+ next->tm_min = alrm->tm_min;
+ next->tm_sec = alrm->tm_sec;
+
+ rtc_tm_to_time(now, &now_time);
+ rtc_tm_to_time(next, &next_time);
+
+ if (next_time < now_time) {
+ /* Advance one day */
+ next_time += 60 * 60 * 24;
+ rtc_time_to_tm(next_time, next);
+ }
+}
+
+static int pm860x_rtc_read_time(struct device *dev, struct rtc_time *tm)
+{
+ struct pm860x_rtc_info *info = dev_get_drvdata(dev);
+ unsigned char buf[8];
+ unsigned long ticks, base, data;
+
+ pm860x_page_bulk_read(info->i2c, REG0_ADDR, 8, buf);
+ dev_dbg(info->dev, "%x-%x-%x-%x-%x-%x-%x-%x\n", buf[0], buf[1],
+ buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);
+ base = (buf[1] << 24) | (buf[3] << 16) | (buf[5] << 8) | buf[7];
+
+ /* load 32-bit read-only counter */
+ pm860x_bulk_read(info->i2c, PM8607_RTC_COUNTER1, 4, buf);
+ data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
+ ticks = base + data;
+ dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
+ base, data, ticks);
+
+ rtc_time_to_tm(ticks, tm);
+
+ return 0;
+}
+
+static int pm860x_rtc_set_time(struct device *dev, struct rtc_time *tm)
+{
+ struct pm860x_rtc_info *info = dev_get_drvdata(dev);
+ unsigned char buf[4];
+ unsigned long ticks, base, data;
+
+ if ((tm->tm_year < 70) || (tm->tm_year > 138)) {
+ dev_dbg(info->dev, "Set time %d out of range. "
+ "Please set time between 1970 to 2038.\n",
+ 1900 + tm->tm_year);
+ return -EINVAL;
+ }
+ rtc_tm_to_time(tm, &ticks);
+
+ /* load 32-bit read-only counter */
+ pm860x_bulk_read(info->i2c, PM8607_RTC_COUNTER1, 4, buf);
+ data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
+ base = ticks - data;
+ dev_dbg(info->dev, "set base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
+ base, data, ticks);
+
+ pm860x_page_reg_write(info->i2c, REG0_DATA, (base >> 24) & 0xFF);
+ pm860x_page_reg_write(info->i2c, REG1_DATA, (base >> 16) & 0xFF);
+ pm860x_page_reg_write(info->i2c, REG2_DATA, (base >> 8) & 0xFF);
+ pm860x_page_reg_write(info->i2c, REG3_DATA, base & 0xFF);
+
+ if (info->sync)
+ info->sync(ticks);
+ return 0;
+}
+
+static int pm860x_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
+{
+ struct pm860x_rtc_info *info = dev_get_drvdata(dev);
+ unsigned char buf[8];
+ unsigned long ticks, base, data;
+ int ret;
+
+ pm860x_page_bulk_read(info->i2c, REG0_ADDR, 8, buf);
+ dev_dbg(info->dev, "%x-%x-%x-%x-%x-%x-%x-%x\n", buf[0], buf[1],
+ buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);
+ base = (buf[1] << 24) | (buf[3] << 16) | (buf[5] << 8) | buf[7];
+
+ pm860x_bulk_read(info->i2c, PM8607_RTC_EXPIRE1, 4, buf);
+ data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
+ ticks = base + data;
+ dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
+ base, data, ticks);
+
+ rtc_time_to_tm(ticks, &alrm->time);
+ ret = pm860x_reg_read(info->i2c, PM8607_RTC1);
+ alrm->enabled = (ret & ALARM_EN) ? 1 : 0;
+ alrm->pending = (ret & (ALARM | ALARM_WAKEUP)) ? 1 : 0;
+ return 0;
+}
+
+static int pm860x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
+{
+ struct pm860x_rtc_info *info = dev_get_drvdata(dev);
+ struct rtc_time now_tm, alarm_tm;
+ unsigned long ticks, base, data;
+ unsigned char buf[8];
+ int mask;
+
+ pm860x_set_bits(info->i2c, PM8607_RTC1, ALARM_EN, 0);
+
+ pm860x_page_bulk_read(info->i2c, REG0_ADDR, 8, buf);
+ dev_dbg(info->dev, "%x-%x-%x-%x-%x-%x-%x-%x\n", buf[0], buf[1],
+ buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);
+ base = (buf[1] << 24) | (buf[3] << 16) | (buf[5] << 8) | buf[7];
+
+ /* load 32-bit read-only counter */
+ pm860x_bulk_read(info->i2c, PM8607_RTC_COUNTER1, 4, buf);
+ data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
+ ticks = base + data;
+ dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
+ base, data, ticks);
+
+ rtc_time_to_tm(ticks, &now_tm);
+ rtc_next_alarm_time(&alarm_tm, &now_tm, &alrm->time);
+ /* get new ticks for alarm in 24 hours */
+ rtc_tm_to_time(&alarm_tm, &ticks);
+ data = ticks - base;
+
+ buf[0] = data & 0xff;
+ buf[1] = (data >> 8) & 0xff;
+ buf[2] = (data >> 16) & 0xff;
+ buf[3] = (data >> 24) & 0xff;
+ pm860x_bulk_write(info->i2c, PM8607_RTC_EXPIRE1, 4, buf);
+ if (alrm->enabled) {
+ mask = ALARM | ALARM_WAKEUP | ALARM_EN;
+ pm860x_set_bits(info->i2c, PM8607_RTC1, mask, mask);
+ } else {
+ mask = ALARM | ALARM_WAKEUP | ALARM_EN;
+ pm860x_set_bits(info->i2c, PM8607_RTC1, mask,
+ ALARM | ALARM_WAKEUP);
+ }
+ return 0;
+}
+
+static const struct rtc_class_ops pm860x_rtc_ops = {
+ .read_time = pm860x_rtc_read_time,
+ .set_time = pm860x_rtc_set_time,
+ .read_alarm = pm860x_rtc_read_alarm,
+ .set_alarm = pm860x_rtc_set_alarm,
+ .alarm_irq_enable = pm860x_rtc_alarm_irq_enable,
+};
+
+#ifdef VRTC_CALIBRATION
+static void calibrate_vrtc_work(struct work_struct *work)
+{
+ struct pm860x_rtc_info *info = container_of(work,
+ struct pm860x_rtc_info, calib_work.work);
+ unsigned char buf[2];
+ unsigned int sum, data, mean, vrtc_set;
+ int i;
+
+ for (i = 0, sum = 0; i < 16; i++) {
+ msleep(100);
+ pm860x_bulk_read(info->i2c, REG_VRTC_MEAS1, 2, buf);
+ data = (buf[0] << 4) | buf[1];
+ data = (data * 5400) >> 12; /* convert to mv */
+ sum += data;
+ }
+ mean = sum >> 4;
+ vrtc_set = 2700 + (info->vrtc & 0x3) * 200;
+ dev_dbg(info->dev, "mean:%d, vrtc_set:%d\n", mean, vrtc_set);
+
+ sum = pm860x_reg_read(info->i2c, PM8607_RTC_MISC1);
+ data = sum & 0x3;
+ if ((mean + 200) < vrtc_set) {
+ /* try higher voltage */
+ if (++data == 4)
+ goto out;
+ data = (sum & 0xf8) | (data & 0x3);
+ pm860x_reg_write(info->i2c, PM8607_RTC_MISC1, data);
+ } else if ((mean - 200) > vrtc_set) {
+ /* try lower voltage */
+ if (data-- == 0)
+ goto out;
+ data = (sum & 0xf8) | (data & 0x3);
+ pm860x_reg_write(info->i2c, PM8607_RTC_MISC1, data);
+ } else
+ goto out;
+ dev_dbg(info->dev, "set 0x%x to RTC_MISC1\n", data);
+ /* trigger next calibration since VRTC is updated */
+ schedule_delayed_work(&info->calib_work, VRTC_CALIB_INTERVAL);
+ return;
+out:
+ /* disable measurement */
+ pm860x_set_bits(info->i2c, PM8607_MEAS_EN2, MEAS2_VRTC, 0);
+ dev_dbg(info->dev, "finish VRTC calibration\n");
+ return;
+}
+#endif
+
+static int __devinit pm860x_rtc_probe(struct platform_device *pdev)
+{
+ struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
+ struct pm860x_rtc_pdata *pdata = NULL;
+ struct pm860x_rtc_info *info;
+ struct rtc_time tm;
+ unsigned long ticks = 0;
+ int ret;
+
+ pdata = pdev->dev.platform_data;
+ if (pdata == NULL) {
+ dev_err(&pdev->dev, "No platform data!\n");
+ return -EINVAL;
+ }
+
+ info = kzalloc(sizeof(struct pm860x_rtc_info), GFP_KERNEL);
+ if (!info)
+ return -ENOMEM;
+ info->irq = platform_get_irq(pdev, 0);
+ if (info->irq < 0) {
+ dev_err(&pdev->dev, "No IRQ resource!\n");
+ ret = -EINVAL;
+ goto out;
+ }
+
+ info->chip = chip;
+ info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion;
+ info->dev = &pdev->dev;
+ dev_set_drvdata(&pdev->dev, info);
+
+ ret = request_threaded_irq(info->irq, NULL, rtc_update_handler,
+ IRQF_ONESHOT, "rtc", info);
+ if (ret < 0) {
+ dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n",
+ info->irq, ret);
+ goto out;
+ }
+
+ /* set addresses of 32-bit base value for RTC time */
+ pm860x_page_reg_write(info->i2c, REG0_ADDR, REG0_DATA);
+ pm860x_page_reg_write(info->i2c, REG1_ADDR, REG1_DATA);
+ pm860x_page_reg_write(info->i2c, REG2_ADDR, REG2_DATA);
+ pm860x_page_reg_write(info->i2c, REG3_ADDR, REG3_DATA);
+
+ ret = pm860x_rtc_read_time(&pdev->dev, &tm);
+ if (ret < 0) {
+ dev_err(&pdev->dev, "Failed to read initial time.\n");
+ goto out_rtc;
+ }
+ if ((tm.tm_year < 70) || (tm.tm_year > 138)) {
+ tm.tm_year = 70;
+ tm.tm_mon = 0;
+ tm.tm_mday = 1;
+ tm.tm_hour = 0;
+ tm.tm_min = 0;
+ tm.tm_sec = 0;
+ ret = pm860x_rtc_set_time(&pdev->dev, &tm);
+ if (ret < 0) {
+ dev_err(&pdev->dev, "Failed to set initial time.\n");
+ goto out_rtc;
+ }
+ }
+ rtc_tm_to_time(&tm, &ticks);
+ if (pdata->sync) {
+ pdata->sync(ticks);
+ info->sync = pdata->sync;
+ }
+
+ info->rtc_dev = rtc_device_register("88pm860x-rtc", &pdev->dev,
+ &pm860x_rtc_ops, THIS_MODULE);
+ ret = PTR_ERR(info->rtc_dev);
+ if (IS_ERR(info->rtc_dev)) {
+ dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret);
+ goto out_rtc;
+ }
+
+ /*
+ * enable internal XO instead of internal 3.25MHz clock since it can
+ * free running in PMIC power-down state.
+ */
+ pm860x_set_bits(info->i2c, PM8607_RTC1, RTC1_USE_XO, RTC1_USE_XO);
+
+#ifdef VRTC_CALIBRATION
+ /* <00> -- 2.7V, <01> -- 2.9V, <10> -- 3.1V, <11> -- 3.3V */
+ info->vrtc = pdata->vrtc & 0x3;
+ pm860x_set_bits(info->i2c, PM8607_MEAS_EN2, MEAS2_VRTC, MEAS2_VRTC);
+
+ /* calibrate VRTC */
+ INIT_DELAYED_WORK(&info->calib_work, calibrate_vrtc_work);
+ schedule_delayed_work(&info->calib_work, VRTC_CALIB_INTERVAL);
+#endif /* VRTC_CALIBRATION */
+ return 0;
+out_rtc:
+ free_irq(info->irq, info);
+out:
+ kfree(info);
+ return ret;
+}
+
+static int __devexit pm860x_rtc_remove(struct platform_device *pdev)
+{
+ struct pm860x_rtc_info *info = platform_get_drvdata(pdev);
+
+#ifdef VRTC_CALIBRATION
+ flush_scheduled_work();
+ /* disable measurement */
+ pm860x_set_bits(info->i2c, PM8607_MEAS_EN2, MEAS2_VRTC, 0);
+#endif /* VRTC_CALIBRATION */
+
+ platform_set_drvdata(pdev, NULL);
+ rtc_device_unregister(info->rtc_dev);
+ free_irq(info->irq, info);
+ kfree(info);
+ return 0;
+}
+
+static struct platform_driver pm860x_rtc_driver = {
+ .driver = {
+ .name = "88pm860x-rtc",
+ .owner = THIS_MODULE,
+ },
+ .probe = pm860x_rtc_probe,
+ .remove = __devexit_p(pm860x_rtc_remove),
+};
+
+static int __init pm860x_rtc_init(void)
+{
+ return platform_driver_register(&pm860x_rtc_driver);
+}
+module_init(pm860x_rtc_init);
+
+static void __exit pm860x_rtc_exit(void)
+{
+ platform_driver_unregister(&pm860x_rtc_driver);
+}
+module_exit(pm860x_rtc_exit);
+
+MODULE_DESCRIPTION("Marvell 88PM860x RTC driver");
+MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/mfd/88pm860x.h b/include/linux/mfd/88pm860x.h
index 8fba797..63b4fb8 100644
--- a/include/linux/mfd/88pm860x.h
+++ b/include/linux/mfd/88pm860x.h
@@ -330,6 +330,11 @@ struct pm860x_led_pdata {
unsigned long flags;
};
+struct pm860x_rtc_pdata {
+ int (*sync)(unsigned int ticks);
+ int vrtc;
+};
+
struct pm860x_touch_pdata {
int gpadc_prebias;
int slot_cycle;
@@ -349,6 +354,7 @@ struct pm860x_power_pdata {
struct pm860x_platform_data {
struct pm860x_backlight_pdata *backlight;
struct pm860x_led_pdata *led;
+ struct pm860x_rtc_pdata *rtc;
struct pm860x_touch_pdata *touch;
struct pm860x_power_pdata *power;
struct regulator_init_data *regulator;
--
1.5.6.5
^ permalink raw reply related [flat|nested] 52+ messages in thread
* [PATCH 04/14] input: set the long press detection in 88pm860x onkey
[not found] <2011041801>
` (3 preceding siblings ...)
2011-04-18 14:04 ` [PATCH 03/14] rtc: add 88pm860x rtc Haojian Zhuang
@ 2011-04-18 14:04 ` Haojian Zhuang
2011-04-18 14:04 ` [PATCH 05/14] w1: add DS278x slave driver Haojian Zhuang
` (9 subsequent siblings)
14 siblings, 0 replies; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-18 14:04 UTC (permalink / raw)
To: sameo, haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo,
johnpol, cbou, dwmw2, lrg, broonie
Cc: Haojian Zhuang
Move the long-press detection from onkey handler to probe function. Avoid
unnecessary I2C operation in onkey handler.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/misc/88pm860x_onkey.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/input/misc/88pm860x_onkey.c b/drivers/input/misc/88pm860x_onkey.c
index 3dca3c1..1abc77e 100644
--- a/drivers/input/misc/88pm860x_onkey.c
+++ b/drivers/input/misc/88pm860x_onkey.c
@@ -50,9 +50,6 @@ static irqreturn_t pm860x_onkey_handler(int irq, void *data)
ret &= ONKEY_STATUS;
input_report_key(info->idev, KEY_POWER, ret);
input_sync(info->idev);
-
- /* Enable 8-second long onkey detection */
- pm860x_set_bits(info->i2c, PM8607_WAKEUP, 3, LONG_ONKEY_EN);
return IRQ_HANDLED;
}
@@ -105,6 +102,9 @@ static int __devinit pm860x_onkey_probe(struct platform_device *pdev)
}
platform_set_drvdata(pdev, info);
+
+ /* Enable 8-second long onkey detection */
+ pm860x_set_bits(info->i2c, PM8607_WAKEUP, 3, LONG_ONKEY_EN);
return 0;
out_irq:
--
1.5.6.5
^ permalink raw reply related [flat|nested] 52+ messages in thread
* [PATCH 05/14] w1: add DS278x slave driver
[not found] <2011041801>
` (4 preceding siblings ...)
2011-04-18 14:04 ` [PATCH 04/14] input: set the long press detection in 88pm860x onkey Haojian Zhuang
@ 2011-04-18 14:04 ` Haojian Zhuang
2011-04-18 14:04 ` [PATCH 06/14] mfd: pxa-w1: MFD driver for PXA 1wire control + DS1WM chip Haojian Zhuang
` (8 subsequent siblings)
14 siblings, 0 replies; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-18 14:04 UTC (permalink / raw)
To: sameo, haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo,
johnpol, cbou, dwmw2, lrg, broonie
Cc: Haojian Zhuang
Append DS278x slave driver.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Cc: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
---
drivers/w1/slaves/Kconfig | 13 +++
drivers/w1/slaves/Makefile | 1 +
drivers/w1/slaves/w1_ds278x.c | 184 +++++++++++++++++++++++++++++++++++++++++
drivers/w1/w1_family.h | 3 +
4 files changed, 201 insertions(+), 0 deletions(-)
create mode 100644 drivers/w1/slaves/w1_ds278x.c
diff --git a/drivers/w1/slaves/Kconfig b/drivers/w1/slaves/Kconfig
index f0c9096..d737aa9 100644
--- a/drivers/w1/slaves/Kconfig
+++ b/drivers/w1/slaves/Kconfig
@@ -61,6 +61,19 @@ config W1_SLAVE_DS2760
If you are unsure, say N.
+config W1_SLAVE_DS278x
+ tristate "Dallas 278x battery monitor chip"
+ depends on W1
+ help
+ If you enable this you will have the DS278x battery monitor
+ chip support.
+
+ The battery monitor chip is used in many batteries/devices
+ as the one who is responsible for charging/discharging/monitoring
+ Li+ batteries.
+
+ If you are unsure, say N.
+
config W1_SLAVE_BQ27000
tristate "BQ27000 slave support"
depends on W1
diff --git a/drivers/w1/slaves/Makefile b/drivers/w1/slaves/Makefile
index 3c76350..bcc134b 100644
--- a/drivers/w1/slaves/Makefile
+++ b/drivers/w1/slaves/Makefile
@@ -8,4 +8,5 @@ obj-$(CONFIG_W1_SLAVE_DS2423) += w1_ds2423.o
obj-$(CONFIG_W1_SLAVE_DS2431) += w1_ds2431.o
obj-$(CONFIG_W1_SLAVE_DS2433) += w1_ds2433.o
obj-$(CONFIG_W1_SLAVE_DS2760) += w1_ds2760.o
+obj-$(CONFIG_W1_SLAVE_DS278x) += w1_ds278x.o
obj-$(CONFIG_W1_SLAVE_BQ27000) += w1_bq27000.o
diff --git a/drivers/w1/slaves/w1_ds278x.c b/drivers/w1/slaves/w1_ds278x.c
new file mode 100644
index 0000000..9da94bb
--- /dev/null
+++ b/drivers/w1/slaves/w1_ds278x.c
@@ -0,0 +1,184 @@
+/*
+ * w1_ds278x.c - w1 family 27 (DS2780/DS2781) driver
+ *
+ * Copyright (c) Intel 2006 Stanley Cai <stanley.cai@intel.com>
+ * Copyright (c) Marvell 2007 Paul Shen <bo.a.shen@marvell.com>
+ *
+ * Modified from w1_ds2433 driver
+ *
+ * Copyright (c) 2005 Ben Gardner <bgardner@wabtec.com>
+ *
+ * This source code is licensed under the GNU General Public License,
+ * Version 2. See the file COPYING for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/device.h>
+#include <linux/types.h>
+#include <linux/delay.h>
+
+#include "../w1.h"
+#include "../w1_int.h"
+#include "../w1_family.h"
+
+#define W1_REG_SIZE 256
+
+#define W1_F27_READ_REG 0x69
+#define W1_F27_WRITE_REG 0x6C
+#define W1_F27_COPY_REG 0x48
+#define W1_F27_RECALL_REG 0xB8
+#define W1_F27_LOCK_REG 0x6A
+
+struct w1_f27_data {
+ u8 memory[W1_REG_SIZE];
+ u32 validcrc;
+};
+
+/**
+ * Check the file size bounds and adjusts count as needed.
+ * This would not be needed if the file size didn't reset to 0 after a write.
+ */
+static inline size_t w1_f27_fix_count(loff_t off, size_t count,
+ size_t size)
+{
+ if (off > size)
+ return 0;
+
+ if ((off + count) > size)
+ return (size - off);
+
+ return count;
+}
+
+static ssize_t w1_f27_read_bin(struct file *fp, struct kobject *kobj,
+ struct bin_attribute *bin_attr,
+ char *buf, loff_t off, size_t count)
+{
+ struct w1_slave *sl = kobj_to_w1_slave(kobj);
+ u8 wrbuf[2];
+
+ count = w1_f27_fix_count(off, count, W1_REG_SIZE);
+ if (count == 0)
+ return 0;
+
+ atomic_inc(&sl->refcnt);
+ mutex_lock(&sl->master->mutex);
+
+ /* read directly from the REG */
+ if (w1_reset_select_slave(sl)) {
+ count = -EIO;
+ goto out_mutex_unlock;
+ }
+
+ wrbuf[0] = W1_F27_READ_REG;
+ wrbuf[1] = off & 0xff;
+ w1_write_block(sl->master, wrbuf, 2);
+ w1_read_block(sl->master, buf, count);
+
+out_mutex_unlock:
+ mutex_unlock(&sl->master->mutex);
+ atomic_dec(&sl->refcnt);
+
+ return count;
+}
+
+static ssize_t w1_f27_write_bin(struct file *fp, struct kobject *kobj,
+ struct bin_attribute *bin_attr,
+ char *buf, loff_t off, size_t count)
+{
+ struct w1_slave *sl = kobj_to_w1_slave(kobj);
+ char wrbuf[2];
+
+ count = w1_f27_fix_count(off, count, W1_REG_SIZE);
+ if (count == 0)
+ return 0;
+
+ atomic_inc(&sl->refcnt);
+ mutex_lock(&sl->master->mutex);
+
+ if (w1_reset_select_slave(sl)) {
+ count = -EIO;
+ goto out_mutex_unlock;
+ }
+
+ wrbuf[0] = W1_F27_WRITE_REG;
+ wrbuf[1] = off & 0xff;
+ w1_write_block(sl->master, wrbuf, 2);
+ w1_write_block(sl->master, buf, count);
+
+out_mutex_unlock:
+ mutex_unlock(&sl->master->mutex);
+ atomic_dec(&sl->refcnt);
+
+ return count;
+}
+
+static struct bin_attribute w1_f27_bin_attr = {
+ .attr = {
+ .name = "registers",
+ .mode = S_IRUGO | S_IWUSR,
+ },
+ .size = W1_REG_SIZE,
+ .read = w1_f27_read_bin,
+ .write = w1_f27_write_bin,
+};
+
+static int w1_f27_add_slave(struct w1_slave *sl)
+{
+ int err;
+
+ err = sysfs_create_bin_file(&sl->dev.kobj, &w1_f27_bin_attr);
+
+ return err;
+}
+
+static void w1_f27_remove_slave(struct w1_slave *sl)
+{
+ sysfs_remove_bin_file(&sl->dev.kobj, &w1_f27_bin_attr);
+}
+
+static struct w1_family_ops w1_f27_fops = {
+ .add_slave = w1_f27_add_slave,
+ .remove_slave = w1_f27_remove_slave,
+};
+
+static struct w1_family w1_family_2780 = {
+ .fid = W1_BATTMON_DS2780,
+ .fops = &w1_f27_fops,
+};
+
+static struct w1_family w1_family_2781 = {
+ .fid = W1_BATTMON_DS2781,
+ .fops = &w1_f27_fops,
+};
+
+static struct w1_family w1_family_2783 = {
+ .fid = W1_BATTMON_DS2783,
+ .fops = &w1_f27_fops,
+};
+
+
+static int __init w1_f27_init(void)
+{
+ pr_info("1-Wire driver for the DS278x battery monitor...\n");
+ return (w1_register_family(&w1_family_2780) |
+ w1_register_family(&w1_family_2781) |
+ w1_register_family(&w1_family_2783));
+}
+
+static void __exit w1_f27_fini(void)
+{
+ w1_unregister_family(&w1_family_2781);
+ w1_unregister_family(&w1_family_2780);
+ w1_unregister_family(&w1_family_2783);
+}
+
+module_init(w1_f27_init);
+module_exit(w1_f27_fini);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Paul Shen <bo.a.shen@marvell.com>");
+MODULE_DESCRIPTION("w1 family 27 driver for DS2780 & DS2781,"
+ " Stand-Alone Fuel Gauge IC");
diff --git a/drivers/w1/w1_family.h b/drivers/w1/w1_family.h
index f3b636d..0f0b58c 100644
--- a/drivers/w1/w1_family.h
+++ b/drivers/w1/w1_family.h
@@ -36,6 +36,9 @@
#define W1_THERM_DS18B20 0x28
#define W1_EEPROM_DS2431 0x2D
#define W1_FAMILY_DS2760 0x30
+#define W1_BATTMON_DS2780 0x32
+#define W1_BATTMON_DS2781 0x3D
+#define W1_BATTMON_DS2783 0x34
#define MAXNAMELEN 32
--
1.5.6.5
^ permalink raw reply related [flat|nested] 52+ messages in thread
* [PATCH 06/14] mfd: pxa-w1: MFD driver for PXA 1wire control + DS1WM chip
[not found] <2011041801>
` (5 preceding siblings ...)
2011-04-18 14:04 ` [PATCH 05/14] w1: add DS278x slave driver Haojian Zhuang
@ 2011-04-18 14:04 ` Haojian Zhuang
2011-04-26 9:48 ` Samuel Ortiz
2011-04-18 14:04 ` [PATCH 07/14] mfd: fix build warning on 88pm860x Haojian Zhuang
` (7 subsequent siblings)
14 siblings, 1 reply; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-18 14:04 UTC (permalink / raw)
To: sameo, haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo,
johnpol, cbou, dwmw2, lrg, broonie
Cc: Haojian Zhuang
This driver provides registers and IRQ of PXA3xx chips to the ds1wm driver.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Cc: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
---
drivers/mfd/Kconfig | 7 ++
drivers/mfd/Makefile | 1 +
drivers/mfd/pxa-w1.c | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 158 insertions(+), 0 deletions(-)
create mode 100644 drivers/mfd/pxa-w1.c
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index e2fea58..b6ecf90 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -34,6 +34,13 @@ config MFD_88PM860X
select individual components like voltage regulators, RTC and
battery-charger under the corresponding menus.
+config MFD_PXA_DS1WM
+ tristate "Support DS1WM chip on Marvell silicons"
+ select MFD_CORE
+ help
+ This core driver provides register access for PXA_DS1WM.
+ Actual functionality is handled by the ds1wm drivers.
+
config MFD_SM501
tristate "Support for Silicon Motion SM501"
---help---
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 419caa9..4f8d1d2 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -4,6 +4,7 @@
88pm860x-objs := 88pm860x-core.o 88pm860x-i2c.o
obj-$(CONFIG_MFD_88PM860X) += 88pm860x.o
+obj-$(CONFIG_MFD_PXA_DS1WM) += pxa-w1.o
obj-$(CONFIG_MFD_SM501) += sm501.o
obj-$(CONFIG_MFD_ASIC3) += asic3.o tmio_core.o
diff --git a/drivers/mfd/pxa-w1.c b/drivers/mfd/pxa-w1.c
new file mode 100644
index 0000000..98074ff
--- /dev/null
+++ b/drivers/mfd/pxa-w1.c
@@ -0,0 +1,150 @@
+/*
+ * Core driver for PXA DS1WM chip.
+ *
+ * Copyright (C) 2010 Marvell <jtzhou@marvell.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/platform_device.h>
+#include <linux/gpio.h>
+#include <linux/io.h>
+#include <linux/irq.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/interrupt.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/ds1wm.h>
+
+struct pxa_w1_info {
+ struct clk *clk;
+};
+
+static int ds1wm_enable(struct platform_device *pdev)
+{
+ struct device *dev = pdev->dev.parent;
+ struct pxa_w1_info *info = dev_get_drvdata(dev);
+
+ clk_enable(info->clk);
+ dev_dbg(dev, "pxa DS1WM clk (active)\n");
+ return 0;
+}
+
+static int ds1wm_disable(struct platform_device *pdev)
+{
+ struct device *dev = pdev->dev.parent;
+ struct pxa_w1_info *info = dev_get_drvdata(dev);
+
+ clk_disable(info->clk);
+ dev_dbg(dev, "pxa DS1WM clk (in-active)\n");
+ return 0;
+}
+
+static struct resource ds1wm_resources[] __devinitdata = {
+ {0, 0, "ds1wm-mem", IORESOURCE_MEM,},
+ {0, 0, "ds1wm-irq", IORESOURCE_IRQ,},
+};
+
+static struct ds1wm_driver_data ds1wm_pdata;
+
+static struct mfd_cell ds1wm_cell __devinitdata = {
+ .name = "ds1wm",
+ .enable = ds1wm_enable,
+ .disable = ds1wm_disable,
+ .platform_data = &ds1wm_pdata,
+ .pdata_size = sizeof(ds1wm_pdata),
+ .num_resources = ARRAY_SIZE(ds1wm_resources),
+ .resources = ds1wm_resources,
+};
+
+static int __devinit pxa_w1_probe(struct platform_device *pdev)
+{
+ struct ds1wm_driver_data *pdata = pdev->dev.platform_data;
+ struct pxa_w1_info *info;
+ struct resource *r;
+ int ret, irq;
+
+ info = kzalloc(sizeof(struct pxa_w1_info), GFP_KERNEL);
+ if (!info)
+ return -ENOMEM;
+
+ r = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+ if (r == NULL) {
+ ret = -ENXIO;
+ goto out;
+ }
+ irq = r->start;
+ if (pdata)
+ ds1wm_pdata.active_high = pdata->active_high;
+ if (ds1wm_pdata.active_high)
+ ds1wm_resources[1].flags |= IORESOURCE_IRQ_HIGHEDGE;
+ else
+ ds1wm_resources[1].flags |= IORESOURCE_IRQ_LOWEDGE;
+
+ r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (r == NULL) {
+ ret = -ENXIO;
+ goto out;
+ }
+ ds1wm_resources[0].end = resource_size(r) - 1;
+
+ info->clk = clk_get(&pdev->dev, NULL);
+ if (IS_ERR(info->clk)) {
+ ret = PTR_ERR(info->clk);
+ goto out;
+ }
+ platform_set_drvdata(pdev, info);
+
+ ds1wm_pdata.clock_rate = clk_get_rate(info->clk);
+ ret = mfd_add_devices(&pdev->dev, pdev->id, &ds1wm_cell, 1, r, irq);
+ if (ret < 0)
+ dev_err(&pdev->dev, "failed to register pxa DS1WM\n");
+
+ return 0;
+out:
+ kfree(info);
+ return ret;
+}
+
+static int __devexit pxa_w1_remove(struct platform_device *pdev)
+{
+ struct pxa_w1_info *info = platform_get_drvdata(pdev);
+
+ mfd_remove_devices(&pdev->dev);
+ clk_put(info->clk);
+ kfree(info);
+ platform_set_drvdata(pdev, NULL);
+ return 0;
+}
+
+static struct platform_driver pxa_w1_driver = {
+ .driver = {
+ .name = "pxa3xx-w1",
+ .owner = THIS_MODULE,
+ },
+ .probe = pxa_w1_probe,
+ .remove = __devexit_p(pxa_w1_remove),
+};
+
+static int __init pxa_w1_base_init(void)
+{
+ return platform_driver_register(&pxa_w1_driver);
+}
+
+static void __exit pxa_w1_base_exit(void)
+{
+ platform_driver_unregister(&pxa_w1_driver);
+}
+
+module_init(pxa_w1_base_init);
+module_exit(pxa_w1_base_exit);
+
+MODULE_AUTHOR("Jett Zhou <jtzhou@marvell.com>");
+MODULE_DESCRIPTION("one wire driver for PXA");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:pxa-w1");
--
1.5.6.5
^ permalink raw reply related [flat|nested] 52+ messages in thread
* [PATCH 07/14] mfd: fix build warning on 88pm860x
[not found] <2011041801>
` (6 preceding siblings ...)
2011-04-18 14:04 ` [PATCH 06/14] mfd: pxa-w1: MFD driver for PXA 1wire control + DS1WM chip Haojian Zhuang
@ 2011-04-18 14:04 ` Haojian Zhuang
2011-04-26 9:49 ` Samuel Ortiz
2011-04-18 14:04 ` [PATCH 08/14] mfd: use platform_data in max8925 Haojian Zhuang
` (6 subsequent siblings)
14 siblings, 1 reply; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-18 14:04 UTC (permalink / raw)
To: sameo, haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo,
johnpol, cbou, dwmw2, lrg, broonie
Cc: Haojian Zhuang
WARNING: vmlinux.o(.devinit.text+0x6c4): Section mismatch in reference
from the function device_onkey_init() to the (unknown reference)
.init.data:(unknown)
The function __devinit device_onkey_init() references a (unknown reference)
__initdata (unknown).
If (unknown) is only used by device_onkey_init then annotate (unknown)
with a matching annotation.
It's caused by using __initdata on mfd cell resources. Replace __initdata
with __devinitdata.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
---
drivers/mfd/88pm860x-core.c | 28 ++++++++++++++--------------
1 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c
index f114ec7..4fbc69b 100644
--- a/drivers/mfd/88pm860x-core.c
+++ b/drivers/mfd/88pm860x-core.c
@@ -21,13 +21,13 @@
#define INT_STATUS_NUM 3
-static struct resource bk_resources[] __initdata = {
+static struct resource bk_resources[] __devinitdata = {
{PM8606_BACKLIGHT1, PM8606_BACKLIGHT1, "backlight-0", IORESOURCE_IO,},
{PM8606_BACKLIGHT2, PM8606_BACKLIGHT2, "backlight-1", IORESOURCE_IO,},
{PM8606_BACKLIGHT3, PM8606_BACKLIGHT3, "backlight-2", IORESOURCE_IO,},
};
-static struct resource led_resources[] __initdata = {
+static struct resource led_resources[] __devinitdata = {
{PM8606_LED1_RED, PM8606_LED1_RED, "led0-red", IORESOURCE_IO,},
{PM8606_LED1_GREEN, PM8606_LED1_GREEN, "led0-green", IORESOURCE_IO,},
{PM8606_LED1_BLUE, PM8606_LED1_BLUE, "led0-blue", IORESOURCE_IO,},
@@ -36,7 +36,7 @@ static struct resource led_resources[] __initdata = {
{PM8606_LED2_BLUE, PM8606_LED2_BLUE, "led1-blue", IORESOURCE_IO,},
};
-static struct resource regulator_resources[] __initdata = {
+static struct resource regulator_resources[] __devinitdata = {
{PM8607_ID_BUCK1, PM8607_ID_BUCK1, "buck-1", IORESOURCE_IO,},
{PM8607_ID_BUCK2, PM8607_ID_BUCK2, "buck-2", IORESOURCE_IO,},
{PM8607_ID_BUCK3, PM8607_ID_BUCK3, "buck-3", IORESOURCE_IO,},
@@ -61,15 +61,15 @@ static struct resource rtc_resources[] __devinitdata = {
{PM8607_IRQ_RTC, PM8607_IRQ_RTC, "rtc", IORESOURCE_IRQ,},
};
-static struct resource touch_resources[] __initdata = {
+static struct resource touch_resources[] __devinitdata = {
{PM8607_IRQ_PEN, PM8607_IRQ_PEN, "touch", IORESOURCE_IRQ,},
};
-static struct resource onkey_resources[] __initdata = {
+static struct resource onkey_resources[] __devinitdata = {
{PM8607_IRQ_ONKEY, PM8607_IRQ_ONKEY, "onkey", IORESOURCE_IRQ,},
};
-static struct resource codec_resources[] __initdata = {
+static struct resource codec_resources[] __devinitdata = {
/* Headset microphone insertion or removal */
{PM8607_IRQ_MICIN, PM8607_IRQ_MICIN, "micin", IORESOURCE_IRQ,},
/* Hook-switch press or release */
@@ -80,12 +80,12 @@ static struct resource codec_resources[] __initdata = {
{PM8607_IRQ_AUDIO_SHORT, PM8607_IRQ_AUDIO_SHORT, "audio-short", IORESOURCE_IRQ,},
};
-static struct resource battery_resources[] __initdata = {
+static struct resource battery_resources[] __devinitdata = {
{PM8607_IRQ_CC, PM8607_IRQ_CC, "columb counter", IORESOURCE_IRQ,},
{PM8607_IRQ_BAT, PM8607_IRQ_BAT, "battery", IORESOURCE_IRQ,},
};
-static struct resource charger_resources[] __initdata = {
+static struct resource charger_resources[] __devinitdata = {
{PM8607_IRQ_CHG, PM8607_IRQ_CHG, "charger detect", IORESOURCE_IRQ,},
{PM8607_IRQ_CHG_DONE, PM8607_IRQ_CHG_DONE, "charging done", IORESOURCE_IRQ,},
{PM8607_IRQ_CHG_FAULT, PM8607_IRQ_CHG_FAULT, "charging timeout", IORESOURCE_IRQ,},
@@ -94,13 +94,13 @@ static struct resource charger_resources[] __initdata = {
{PM8607_IRQ_VCHG, PM8607_IRQ_VCHG, "vchg voltage", IORESOURCE_IRQ,},
};
-static struct mfd_cell bk_devs[] __initdata = {
+static struct mfd_cell bk_devs[] = {
{"88pm860x-backlight", 0,},
{"88pm860x-backlight", 1,},
{"88pm860x-backlight", 2,},
};
-static struct mfd_cell led_devs[] __initdata = {
+static struct mfd_cell led_devs[] = {
{"88pm860x-led", 0,},
{"88pm860x-led", 1,},
{"88pm860x-led", 2,},
@@ -109,7 +109,7 @@ static struct mfd_cell led_devs[] __initdata = {
{"88pm860x-led", 5,},
};
-static struct mfd_cell regulator_devs[] __initdata = {
+static struct mfd_cell regulator_devs[] = {
{"88pm860x-regulator", 0,},
{"88pm860x-regulator", 1,},
{"88pm860x-regulator", 2,},
@@ -134,15 +134,15 @@ static struct mfd_cell rtc_devs[] = {
{"88pm860x-rtc", -1,},
};
-static struct mfd_cell touch_devs[] __initdata = {
+static struct mfd_cell touch_devs[] = {
{"88pm860x-touch", -1,},
};
-static struct mfd_cell onkey_devs[] __initdata = {
+static struct mfd_cell onkey_devs[] = {
{"88pm860x-onkey", -1,},
};
-static struct mfd_cell codec_devs[] __initdata = {
+static struct mfd_cell codec_devs[] = {
{"88pm860x-codec", -1,},
};
--
1.5.6.5
^ permalink raw reply related [flat|nested] 52+ messages in thread
* [PATCH 08/14] mfd: use platform_data in max8925
[not found] <2011041801>
` (7 preceding siblings ...)
2011-04-18 14:04 ` [PATCH 07/14] mfd: fix build warning on 88pm860x Haojian Zhuang
@ 2011-04-18 14:04 ` Haojian Zhuang
2011-04-20 11:54 ` Haojian Zhuang
2011-04-18 14:04 ` [PATCH 09/14] input: get irq from resource in max8925 onkey Haojian Zhuang
` (5 subsequent siblings)
14 siblings, 1 reply; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-18 14:04 UTC (permalink / raw)
To: sameo, haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo,
johnpol, cbou, dwmw2, lrg, broonie
Cc: Haojian Zhuang
Use platform_data to pass parameters to client driver.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
---
drivers/mfd/max8925-core.c | 467 +++++++++++++++++++++++++------------------
include/linux/mfd/max8925.h | 9 +-
2 files changed, 274 insertions(+), 202 deletions(-)
diff --git a/drivers/mfd/max8925-core.c b/drivers/mfd/max8925-core.c
index 58cc5fd..044801c 100644
--- a/drivers/mfd/max8925-core.c
+++ b/drivers/mfd/max8925-core.c
@@ -17,169 +17,141 @@
#include <linux/platform_device.h>
#include <linux/mfd/core.h>
#include <linux/mfd/max8925.h>
+#include <linux/regulator/machine.h>
-static struct resource backlight_resources[] = {
- {
- .name = "max8925-backlight",
- .start = MAX8925_WLED_MODE_CNTL,
- .end = MAX8925_WLED_CNTL,
- .flags = IORESOURCE_IO,
- },
+static struct resource bk_resources[] __devinitdata = {
+ {0, 0, "max8925-backlight", IORESOURCE_IO,},
};
-static struct mfd_cell backlight_devs[] = {
- {
- .name = "max8925-backlight",
- .num_resources = 1,
- .resources = &backlight_resources[0],
- .id = -1,
- },
+static struct resource touch_resources[] __devinitdata = {
+ {MAX8925_IRQ_TSC_STICK, MAX8925_IRQ_TSC_STICK, "touch stick",
+ IORESOURCE_IRQ,},
+ {MAX8925_IRQ_TSC_NSTICK, MAX8925_IRQ_TSC_NSTICK, "touch nstick",
+ IORESOURCE_IRQ,},
};
-static struct resource touch_resources[] = {
- {
- .name = "max8925-tsc",
- .start = MAX8925_TSC_IRQ,
- .end = MAX8925_ADC_RES_END,
- .flags = IORESOURCE_IO,
- },
+static struct resource power_resources[] __devinitdata = {
+ {MAX8925_IRQ_VCHG_DC_OVP, MAX8925_IRQ_VCHG_DC_OVP, \
+ "dc overvoltage", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_DC_F, MAX8925_IRQ_VCHG_DC_F, \
+ "dc falling", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_DC_R, MAX8925_IRQ_VCHG_DC_R, \
+ "dc rising", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_USB_OVP, MAX8925_IRQ_VCHG_USB_OVP, \
+ "usb overvoltage", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_USB_F, MAX8925_IRQ_VCHG_USB_F, \
+ "usb falling", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_USB_R, MAX8925_IRQ_VCHG_USB_R, \
+ "usb rising", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_THM_OK_R, MAX8925_IRQ_VCHG_THM_OK_R, \
+ "bat temp valid", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_THM_OK_F, MAX8925_IRQ_VCHG_THM_OK_F, \
+ "bat temp invalid", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_SYSLOW_F, MAX8925_IRQ_VCHG_SYSLOW_F, \
+ "VSYSLOW falling", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_SYSLOW_R, MAX8925_IRQ_VCHG_SYSLOW_R, \
+ "VSYSLOW rising", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_RST, MAX8925_IRQ_VCHG_RST, \
+ "charger restart", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_DONE, MAX8925_IRQ_VCHG_DONE, \
+ "charger done", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_TOPOFF, MAX8925_IRQ_VCHG_TOPOFF, \
+ "charger topoff", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_TMR_FAULT, MAX8925_IRQ_VCHG_TMR_FAULT, \
+ "charger expire", IORESOURCE_IRQ,},
};
-static struct mfd_cell touch_devs[] = {
- {
- .name = "max8925-touch",
- .num_resources = 1,
- .resources = &touch_resources[0],
- .id = -1,
- },
+static struct resource rtc_resources[] __devinitdata = {
+ {MAX8925_IRQ_RTC_ALARM0, MAX8925_IRQ_RTC_ALARM0, "rtc-alarm0",
+ IORESOURCE_IRQ,},
+ {MAX8925_IRQ_RTC_ALARM1, MAX8925_IRQ_RTC_ALARM1, "rtc-alarm1",
+ IORESOURCE_IRQ,},
};
-static struct resource power_supply_resources[] = {
- {
- .name = "max8925-power",
- .start = MAX8925_CHG_IRQ1,
- .end = MAX8925_CHG_IRQ1_MASK,
- .flags = IORESOURCE_IO,
- },
+static struct resource onkey_resources[] __devinitdata = {
+ {MAX8925_IRQ_GPM_SW_R, MAX8925_IRQ_GPM_SW_R, "onkey R",
+ IORESOURCE_IRQ,},
+ {MAX8925_IRQ_GPM_SW_F, MAX8925_IRQ_GPM_SW_F, "onkey F",
+ IORESOURCE_IRQ,},
};
-static struct mfd_cell power_devs[] = {
- {
- .name = "max8925-power",
- .num_resources = 1,
- .resources = &power_supply_resources[0],
- .id = -1,
- },
+static struct resource regulator_resources[] __devinitdata = {
+ {MAX8925_ID_SD1, MAX8925_ID_SD1, "SD1", IORESOURCE_IO,},
+ {MAX8925_ID_SD2, MAX8925_ID_SD2, "SD2", IORESOURCE_IO,},
+ {MAX8925_ID_SD3, MAX8925_ID_SD3, "SD3", IORESOURCE_IO,},
+ {MAX8925_ID_LDO1, MAX8925_ID_LDO1, "LDO01", IORESOURCE_IO,},
+ {MAX8925_ID_LDO2, MAX8925_ID_LDO2, "LDO02", IORESOURCE_IO,},
+ {MAX8925_ID_LDO3, MAX8925_ID_LDO3, "LDO03", IORESOURCE_IO,},
+ {MAX8925_ID_LDO4, MAX8925_ID_LDO4, "LDO04", IORESOURCE_IO,},
+ {MAX8925_ID_LDO5, MAX8925_ID_LDO5, "LDO05", IORESOURCE_IO,},
+ {MAX8925_ID_LDO6, MAX8925_ID_LDO6, "LDO06", IORESOURCE_IO,},
+ {MAX8925_ID_LDO7, MAX8925_ID_LDO7, "LDO07", IORESOURCE_IO,},
+ {MAX8925_ID_LDO8, MAX8925_ID_LDO8, "LDO08", IORESOURCE_IO,},
+ {MAX8925_ID_LDO9, MAX8925_ID_LDO9, "LDO09", IORESOURCE_IO,},
+ {MAX8925_ID_LDO10, MAX8925_ID_LDO10, "LDO10", IORESOURCE_IO,},
+ {MAX8925_ID_LDO11, MAX8925_ID_LDO11, "LDO11", IORESOURCE_IO,},
+ {MAX8925_ID_LDO12, MAX8925_ID_LDO12, "LDO12", IORESOURCE_IO,},
+ {MAX8925_ID_LDO13, MAX8925_ID_LDO13, "LDO13", IORESOURCE_IO,},
+ {MAX8925_ID_LDO14, MAX8925_ID_LDO14, "LDO14", IORESOURCE_IO,},
+ {MAX8925_ID_LDO15, MAX8925_ID_LDO15, "LDO15", IORESOURCE_IO,},
+ {MAX8925_ID_LDO16, MAX8925_ID_LDO16, "LDO16", IORESOURCE_IO,},
+ {MAX8925_ID_LDO17, MAX8925_ID_LDO17, "LDO17", IORESOURCE_IO,},
+ {MAX8925_ID_LDO18, MAX8925_ID_LDO18, "LDO18", IORESOURCE_IO,},
+ {MAX8925_ID_LDO19, MAX8925_ID_LDO19, "LDO19", IORESOURCE_IO,},
+ {MAX8925_ID_LDO20, MAX8925_ID_LDO20, "LDO20", IORESOURCE_IO,},
};
-static struct resource rtc_resources[] = {
- {
- .name = "max8925-rtc",
- .start = MAX8925_RTC_IRQ,
- .end = MAX8925_RTC_IRQ_MASK,
- .flags = IORESOURCE_IO,
- },
+static struct mfd_cell bk_devs[] = {
+ {"max8925-backlight", -1,},
};
-static struct mfd_cell rtc_devs[] = {
- {
- .name = "max8925-rtc",
- .num_resources = 1,
- .resources = &rtc_resources[0],
- .id = -1,
- },
+static struct mfd_cell touch_devs[] = {
+ {"max8925-touch", -1,},
};
-static struct resource onkey_resources[] = {
- {
- .name = "max8925-onkey",
- .start = MAX8925_IRQ_GPM_SW_R,
- .end = MAX8925_IRQ_GPM_SW_R,
- .flags = IORESOURCE_IRQ,
- }, {
- .name = "max8925-onkey",
- .start = MAX8925_IRQ_GPM_SW_F,
- .end = MAX8925_IRQ_GPM_SW_F,
- .flags = IORESOURCE_IRQ,
- },
+static struct mfd_cell power_devs[] = {
+ {"max8925-power", -1,},
};
-static struct mfd_cell onkey_devs[] = {
- {
- .name = "max8925-onkey",
- .num_resources = 2,
- .resources = &onkey_resources[0],
- .id = -1,
- },
+static struct mfd_cell rtc_devs[] = {
+ {"max8925-rtc", -1,},
};
-#define MAX8925_REG_RESOURCE(_start, _end) \
-{ \
- .start = MAX8925_##_start, \
- .end = MAX8925_##_end, \
- .flags = IORESOURCE_IO, \
-}
-
-static struct resource regulator_resources[] = {
- MAX8925_REG_RESOURCE(SDCTL1, SDCTL1),
- MAX8925_REG_RESOURCE(SDCTL2, SDCTL2),
- MAX8925_REG_RESOURCE(SDCTL3, SDCTL3),
- MAX8925_REG_RESOURCE(LDOCTL1, LDOCTL1),
- MAX8925_REG_RESOURCE(LDOCTL2, LDOCTL2),
- MAX8925_REG_RESOURCE(LDOCTL3, LDOCTL3),
- MAX8925_REG_RESOURCE(LDOCTL4, LDOCTL4),
- MAX8925_REG_RESOURCE(LDOCTL5, LDOCTL5),
- MAX8925_REG_RESOURCE(LDOCTL6, LDOCTL6),
- MAX8925_REG_RESOURCE(LDOCTL7, LDOCTL7),
- MAX8925_REG_RESOURCE(LDOCTL8, LDOCTL8),
- MAX8925_REG_RESOURCE(LDOCTL9, LDOCTL9),
- MAX8925_REG_RESOURCE(LDOCTL10, LDOCTL10),
- MAX8925_REG_RESOURCE(LDOCTL11, LDOCTL11),
- MAX8925_REG_RESOURCE(LDOCTL12, LDOCTL12),
- MAX8925_REG_RESOURCE(LDOCTL13, LDOCTL13),
- MAX8925_REG_RESOURCE(LDOCTL14, LDOCTL14),
- MAX8925_REG_RESOURCE(LDOCTL15, LDOCTL15),
- MAX8925_REG_RESOURCE(LDOCTL16, LDOCTL16),
- MAX8925_REG_RESOURCE(LDOCTL17, LDOCTL17),
- MAX8925_REG_RESOURCE(LDOCTL18, LDOCTL18),
- MAX8925_REG_RESOURCE(LDOCTL19, LDOCTL19),
- MAX8925_REG_RESOURCE(LDOCTL20, LDOCTL20),
+static struct mfd_cell onkey_devs[] = {
+ {"max8925-onkey", -1,},
};
-#define MAX8925_REG_DEVS(_id) \
-{ \
- .name = "max8925-regulator", \
- .num_resources = 1, \
- .resources = ®ulator_resources[MAX8925_ID_##_id], \
- .id = MAX8925_ID_##_id, \
-}
-
static struct mfd_cell regulator_devs[] = {
- MAX8925_REG_DEVS(SD1),
- MAX8925_REG_DEVS(SD2),
- MAX8925_REG_DEVS(SD3),
- MAX8925_REG_DEVS(LDO1),
- MAX8925_REG_DEVS(LDO2),
- MAX8925_REG_DEVS(LDO3),
- MAX8925_REG_DEVS(LDO4),
- MAX8925_REG_DEVS(LDO5),
- MAX8925_REG_DEVS(LDO6),
- MAX8925_REG_DEVS(LDO7),
- MAX8925_REG_DEVS(LDO8),
- MAX8925_REG_DEVS(LDO9),
- MAX8925_REG_DEVS(LDO10),
- MAX8925_REG_DEVS(LDO11),
- MAX8925_REG_DEVS(LDO12),
- MAX8925_REG_DEVS(LDO13),
- MAX8925_REG_DEVS(LDO14),
- MAX8925_REG_DEVS(LDO15),
- MAX8925_REG_DEVS(LDO16),
- MAX8925_REG_DEVS(LDO17),
- MAX8925_REG_DEVS(LDO18),
- MAX8925_REG_DEVS(LDO19),
- MAX8925_REG_DEVS(LDO20),
+ {"max8925-regulator", 0,},
+ {"max8925-regulator", 1,},
+ {"max8925-regulator", 2,},
+ {"max8925-regulator", 3,},
+ {"max8925-regulator", 4,},
+ {"max8925-regulator", 5,},
+ {"max8925-regulator", 6,},
+ {"max8925-regulator", 7,},
+ {"max8925-regulator", 8,},
+ {"max8925-regulator", 9,},
+ {"max8925-regulator", 10,},
+ {"max8925-regulator", 11,},
+ {"max8925-regulator", 12,},
+ {"max8925-regulator", 13,},
+ {"max8925-regulator", 14,},
+ {"max8925-regulator", 15,},
+ {"max8925-regulator", 16,},
+ {"max8925-regulator", 17,},
+ {"max8925-regulator", 18,},
+ {"max8925-regulator", 19,},
+ {"max8925-regulator", 20,},
+ {"max8925-regulator", 21,},
+ {"max8925-regulator", 22,},
};
+static struct max8925_backlight_pdata bk_pdata;
+static struct max8925_touch_pdata touch_pdata;
+static struct max8925_power_pdata power_pdata;
+static struct regulator_init_data regulator_pdata[ARRAY_SIZE(regulator_devs)];
+
enum {
FLAGS_ADC = 1, /* register in ADC component */
FLAGS_RTC, /* register in RTC component */
@@ -588,6 +560,159 @@ tsc_irq:
return 0;
}
+static void __devinit device_bk_init(struct max8925_chip *chip,
+ struct i2c_client *i2c,
+ struct max8925_platform_data *pdata)
+{
+ int ret;
+
+ if ((pdata == NULL) || (pdata->backlight == NULL))
+ return;
+
+ memcpy(&bk_pdata, pdata->backlight,
+ sizeof(struct max8925_backlight_pdata));
+ bk_devs[0].platform_data = &bk_pdata;
+ bk_devs[0].pdata_size = sizeof(bk_pdata);
+
+ bk_devs[0].num_resources = 1;
+ bk_devs[0].resources = &bk_resources[0];
+ ret = mfd_add_devices(chip->dev, 0, &bk_devs[0], 1,
+ &bk_resources[0], 0);
+ if (ret < 0)
+ dev_err(chip->dev, "Failed to add backlight subdev\n");
+}
+
+static void __devinit device_rtc_init(struct max8925_chip *chip,
+ struct i2c_client *i2c,
+ struct max8925_platform_data *pdata)
+{
+ int ret;
+
+ rtc_devs[0].num_resources = ARRAY_SIZE(rtc_resources);
+ rtc_devs[0].resources = &rtc_resources[0];
+ ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0], 1,
+ &rtc_resources[0], chip->irq_base);
+ if (ret < 0)
+ dev_err(chip->dev, "Failed to add rtc subdev\n");
+}
+
+static void __devinit device_touch_init(struct max8925_chip *chip,
+ struct i2c_client *i2c,
+ struct max8925_platform_data *pdata)
+{
+ int ret;
+
+ if ((pdata == NULL) || (pdata->touch == NULL))
+ return;
+
+ memcpy(&touch_pdata, pdata->touch,
+ sizeof(struct max8925_touch_pdata));
+ touch_devs[0].platform_data = &touch_pdata;
+ touch_devs[0].pdata_size = sizeof(touch_pdata);
+ touch_devs[0].num_resources = ARRAY_SIZE(touch_resources);
+ touch_devs[0].resources = &touch_resources[0];
+ ret = mfd_add_devices(chip->dev, 0, &touch_devs[0],
+ ARRAY_SIZE(touch_devs),
+ &touch_resources[0], chip->irq_base);
+ if (ret < 0)
+ dev_err(chip->dev, "Failed to add touch subdev\n");
+}
+
+static void __devinit device_power_init(struct max8925_chip *chip,
+ struct i2c_client *i2c,
+ struct max8925_platform_data *pdata)
+{
+ int ret;
+
+ if ((pdata == NULL) || (pdata->power == NULL))
+ return;
+
+ memcpy(&power_pdata, pdata->power,
+ sizeof(struct max8925_power_pdata));
+ power_devs[0].platform_data = &power_pdata;
+ power_devs[0].pdata_size = sizeof(power_pdata);
+ power_devs[0].num_resources = ARRAY_SIZE(power_resources);
+ power_devs[0].resources = &power_resources[0];
+ ret = mfd_add_devices(chip->dev, 0, &power_devs[0],
+ ARRAY_SIZE(power_devs),
+ &power_resources[0], chip->irq_base);
+ if (ret < 0)
+ dev_err(chip->dev, "Failed to add power supply subdev\n");
+}
+
+static void __devinit device_onkey_init(struct max8925_chip *chip,
+ struct i2c_client *i2c,
+ struct max8925_platform_data *pdata)
+{
+ int ret;
+
+ onkey_devs[0].num_resources = ARRAY_SIZE(onkey_resources);
+ onkey_devs[0].resources = &onkey_resources[0];
+ ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0],
+ ARRAY_SIZE(onkey_devs),
+ &onkey_resources[0], chip->irq_base);
+ if (ret < 0)
+ dev_err(chip->dev, "Failed to add onkey subdev\n");
+}
+
+static void __devinit device_regulator_init(struct max8925_chip *chip,
+ struct i2c_client *i2c,
+ struct max8925_platform_data *pdata)
+{
+ struct regulator_init_data *initdata;
+ int ret, i, j;
+
+ if ((pdata == NULL) || (pdata->regulator == NULL))
+ return;
+
+ if (pdata->num_regulators > ARRAY_SIZE(regulator_devs))
+ pdata->num_regulators = ARRAY_SIZE(regulator_devs);
+
+ for (i = 0, j = -1; i < pdata->num_regulators; i++) {
+ initdata = &pdata->regulator[i];
+ if (strstr(initdata->constraints.name, "SD")) {
+ sscanf(initdata->constraints.name, "SD%d", &j);
+ /* SD1 ~ SD3 */
+ if ((j < 1) || (j > 3)) {
+ dev_err(chip->dev, "Failed to add constraint "
+ "(%s)\n", initdata->constraints.name);
+ goto out;
+ }
+ j = (j - 1) + MAX8925_ID_SD1;
+ }
+ if (strstr(initdata->constraints.name, "LDO")) {
+ sscanf(initdata->constraints.name, "LDO%d", &j);
+ /* LDO01 ~ LDO20 */
+ if ((j < 1) || (j > 20)) {
+ dev_err(chip->dev, "Failed to add constraint "
+ "(%s)\n", initdata->constraints.name);
+ goto out;
+ }
+ j = (j - 1) + MAX8925_ID_LDO1;
+ }
+ if (j == -1) {
+ dev_err(chip->dev, "Failed to add constraint (%s)\n",
+ initdata->constraints.name);
+ goto out;
+ }
+ memcpy(®ulator_pdata[i], &pdata->regulator[i],
+ sizeof(struct regulator_init_data));
+ regulator_devs[i].platform_data = ®ulator_pdata[i];
+ regulator_devs[i].pdata_size = sizeof(regulator_pdata[i]);
+ regulator_devs[i].num_resources = 1;
+ regulator_devs[i].resources = ®ulator_resources[j];
+
+ ret = mfd_add_devices(chip->dev, 0, ®ulator_devs[i], 1,
+ ®ulator_resources[j], 0);
+ if (ret < 0) {
+ dev_err(chip->dev, "Failed to add regulator subdev\n");
+ goto out;
+ }
+ }
+out:
+ return;
+}
+
int __devinit max8925_device_init(struct max8925_chip *chip,
struct max8925_platform_data *pdata)
{
@@ -604,75 +729,21 @@ int __devinit max8925_device_init(struct max8925_chip *chip,
do {
ret = max8925_reg_read(chip->adc, MAX8925_TSC_IRQ);
} while (ret & MAX8925_NREF_OK);
- /* enaable ADC scheduler, interval is 1 second */
+ /* enable ADC scheduler, interval is 1 second */
max8925_set_bits(chip->adc, MAX8925_ADC_SCHED, 3, 2);
}
/* enable Momentary Power Loss */
max8925_set_bits(chip->rtc, MAX8925_MPL_CNTL, 1 << 4, 1 << 4);
- ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0],
- ARRAY_SIZE(rtc_devs),
- &rtc_resources[0], 0);
- if (ret < 0) {
- dev_err(chip->dev, "Failed to add rtc subdev\n");
- goto out;
- }
-
- ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0],
- ARRAY_SIZE(onkey_devs),
- &onkey_resources[0], 0);
- if (ret < 0) {
- dev_err(chip->dev, "Failed to add onkey subdev\n");
- goto out_dev;
- }
-
- if (pdata && pdata->regulator[0]) {
- ret = mfd_add_devices(chip->dev, 0, ®ulator_devs[0],
- ARRAY_SIZE(regulator_devs),
- ®ulator_resources[0], 0);
- if (ret < 0) {
- dev_err(chip->dev, "Failed to add regulator subdev\n");
- goto out_dev;
- }
- }
-
- if (pdata && pdata->backlight) {
- ret = mfd_add_devices(chip->dev, 0, &backlight_devs[0],
- ARRAY_SIZE(backlight_devs),
- &backlight_resources[0], 0);
- if (ret < 0) {
- dev_err(chip->dev, "Failed to add backlight subdev\n");
- goto out_dev;
- }
- }
-
- if (pdata && pdata->power) {
- ret = mfd_add_devices(chip->dev, 0, &power_devs[0],
- ARRAY_SIZE(power_devs),
- &power_supply_resources[0], 0);
- if (ret < 0) {
- dev_err(chip->dev, "Failed to add power supply "
- "subdev\n");
- goto out_dev;
- }
- }
-
- if (pdata && pdata->touch) {
- ret = mfd_add_devices(chip->dev, 0, &touch_devs[0],
- ARRAY_SIZE(touch_devs),
- &touch_resources[0], 0);
- if (ret < 0) {
- dev_err(chip->dev, "Failed to add touch subdev\n");
- goto out_dev;
- }
- }
+ device_bk_init(chip, chip->i2c, pdata);
+ device_rtc_init(chip, chip->rtc, pdata);
+ device_touch_init(chip, chip->adc, pdata);
+ device_power_init(chip, chip->adc, pdata);
+ device_onkey_init(chip, chip->i2c, pdata);
+ device_regulator_init(chip, chip->i2c, pdata);
return 0;
-out_dev:
- mfd_remove_devices(chip->dev);
-out:
- return ret;
}
void __devexit max8925_device_exit(struct max8925_chip *chip)
diff --git a/include/linux/mfd/max8925.h b/include/linux/mfd/max8925.h
index 5259dfe..51578e2 100644
--- a/include/linux/mfd/max8925.h
+++ b/include/linux/mfd/max8925.h
@@ -209,9 +209,9 @@ struct max8925_chip {
};
struct max8925_backlight_pdata {
- int lxw_scl; /* 0/1 -- 0.8Ohm/0.4Ohm */
- int lxw_freq; /* 700KHz ~ 1400KHz */
- int dual_string; /* 0/1 -- single/dual string */
+ int lxw_scl; /* 0/1 -- 0.8Ohm/0.4Ohm */
+ int lxw_freq; /* 700KHz ~ 1400KHz */
+ int dual_string; /* 0/1 -- single/dual string */
};
struct max8925_touch_pdata {
@@ -233,10 +233,11 @@ struct max8925_platform_data {
struct max8925_backlight_pdata *backlight;
struct max8925_touch_pdata *touch;
struct max8925_power_pdata *power;
- struct regulator_init_data *regulator[MAX8925_MAX_REGULATOR];
+ struct regulator_init_data *regulator;
int irq_base;
int tsc_irq;
+ int num_regulators;
};
extern int max8925_reg_read(struct i2c_client *, int);
--
1.5.6.5
^ permalink raw reply related [flat|nested] 52+ messages in thread
* [PATCH 09/14] input: get irq from resource in max8925 onkey
[not found] <2011041801>
` (8 preceding siblings ...)
2011-04-18 14:04 ` [PATCH 08/14] mfd: use platform_data in max8925 Haojian Zhuang
@ 2011-04-18 14:04 ` Haojian Zhuang
2011-04-18 14:04 ` [PATCH 10/14] rtc: avoid to use hardcoding irq number in max8925 Haojian Zhuang
` (4 subsequent siblings)
14 siblings, 0 replies; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-18 14:04 UTC (permalink / raw)
To: sameo, haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo,
johnpol, cbou, dwmw2, lrg, broonie
Cc: Haojian Zhuang
Avoid to use hardcoding irq numbers in max8925 onkey driver. Get irq
from resources instead.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/misc/max8925_onkey.c | 36 ++++++++++++++++--------------------
1 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/drivers/input/misc/max8925_onkey.c b/drivers/input/misc/max8925_onkey.c
index 7de0ded..835cc2a 100644
--- a/drivers/input/misc/max8925_onkey.c
+++ b/drivers/input/misc/max8925_onkey.c
@@ -69,18 +69,7 @@ static int __devinit max8925_onkey_probe(struct platform_device *pdev)
{
struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
struct max8925_onkey_info *info;
- int irq[2], error;
-
- irq[0] = platform_get_irq(pdev, 0);
- if (irq[0] < 0) {
- dev_err(&pdev->dev, "No IRQ resource!\n");
- return -EINVAL;
- }
- irq[1] = platform_get_irq(pdev, 1);
- if (irq[1] < 0) {
- dev_err(&pdev->dev, "No IRQ resource!\n");
- return -EINVAL;
- }
+ int error = -EINVAL;
info = kzalloc(sizeof(struct max8925_onkey_info), GFP_KERNEL);
if (!info)
@@ -88,21 +77,30 @@ static int __devinit max8925_onkey_probe(struct platform_device *pdev)
info->i2c = chip->i2c;
info->dev = &pdev->dev;
- irq[0] += chip->irq_base;
- irq[1] += chip->irq_base;
- error = request_threaded_irq(irq[0], NULL, max8925_onkey_handler,
+ info->irq[0] = platform_get_irq(pdev, 0);
+ if (info->irq[0] < 0) {
+ dev_err(&pdev->dev, "No IRQ resource!\n");
+ goto out;
+ }
+ info->irq[1] = platform_get_irq(pdev, 1);
+ if (info->irq[1] < 0) {
+ dev_err(&pdev->dev, "No IRQ resource!\n");
+ goto out;
+ }
+
+ error = request_threaded_irq(info->irq[0], NULL, max8925_onkey_handler,
IRQF_ONESHOT, "onkey-down", info);
if (error < 0) {
dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n",
- irq[0], error);
+ info->irq[0], error);
goto out;
}
- error = request_threaded_irq(irq[1], NULL, max8925_onkey_handler,
+ error = request_threaded_irq(info->irq[1], NULL, max8925_onkey_handler,
IRQF_ONESHOT, "onkey-up", info);
if (error < 0) {
dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n",
- irq[1], error);
+ info->irq[1], error);
goto out_irq;
}
@@ -117,8 +115,6 @@ static int __devinit max8925_onkey_probe(struct platform_device *pdev)
info->idev->phys = "max8925_on/input0";
info->idev->id.bustype = BUS_I2C;
info->idev->dev.parent = &pdev->dev;
- info->irq[0] = irq[0];
- info->irq[1] = irq[1];
info->idev->evbit[0] = BIT_MASK(EV_KEY);
info->idev->keybit[BIT_WORD(KEY_POWER)] = BIT_MASK(KEY_POWER);
--
1.5.6.5
^ permalink raw reply related [flat|nested] 52+ messages in thread
* [PATCH 10/14] rtc: avoid to use hardcoding irq number in max8925
[not found] <2011041801>
` (9 preceding siblings ...)
2011-04-18 14:04 ` [PATCH 09/14] input: get irq from resource in max8925 onkey Haojian Zhuang
@ 2011-04-18 14:04 ` Haojian Zhuang
2011-04-18 14:04 ` [PATCH 11/14] power_supply: max8925: use platform_data from cell Haojian Zhuang
` (3 subsequent siblings)
14 siblings, 0 replies; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-18 14:04 UTC (permalink / raw)
To: sameo, haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo,
johnpol, cbou, dwmw2, lrg, broonie
Cc: Haojian Zhuang
Avoid to use hardcoding irq number in max8925 rtc driver. Use irq number
from resources instead.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
---
drivers/rtc/rtc-max8925.c | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/drivers/rtc/rtc-max8925.c b/drivers/rtc/rtc-max8925.c
index 174036d..c460152 100644
--- a/drivers/rtc/rtc-max8925.c
+++ b/drivers/rtc/rtc-max8925.c
@@ -69,6 +69,7 @@ struct max8925_rtc_info {
struct max8925_chip *chip;
struct i2c_client *rtc;
struct device *dev;
+ int irq;
};
static irqreturn_t rtc_update_handler(int irq, void *data)
@@ -239,7 +240,7 @@ static int __devinit max8925_rtc_probe(struct platform_device *pdev)
{
struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
struct max8925_rtc_info *info;
- int irq, ret;
+ int ret = -EINVAL;
info = kzalloc(sizeof(struct max8925_rtc_info), GFP_KERNEL);
if (!info)
@@ -247,16 +248,22 @@ static int __devinit max8925_rtc_probe(struct platform_device *pdev)
info->chip = chip;
info->rtc = chip->rtc;
info->dev = &pdev->dev;
- irq = chip->irq_base + MAX8925_IRQ_RTC_ALARM0;
+ info->irq = platform_get_irq(pdev, 0);
+ if (info->irq < 0) {
+ dev_err(chip->dev, "Failed to get IRQ resource\n");
+ goto out_irq;
+ }
- ret = request_threaded_irq(irq, NULL, rtc_update_handler,
+ ret = request_threaded_irq(info->irq, NULL, rtc_update_handler,
IRQF_ONESHOT, "rtc-alarm0", info);
if (ret < 0) {
dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n",
- irq, ret);
+ info->irq, ret);
goto out_irq;
}
+ dev_set_drvdata(&pdev->dev, info);
+ platform_set_drvdata(pdev, info);
info->rtc_dev = rtc_device_register("max8925-rtc", &pdev->dev,
&max8925_rtc_ops, THIS_MODULE);
ret = PTR_ERR(info->rtc_dev);
@@ -265,12 +272,9 @@ static int __devinit max8925_rtc_probe(struct platform_device *pdev)
goto out_rtc;
}
- dev_set_drvdata(&pdev->dev, info);
- platform_set_drvdata(pdev, info);
-
return 0;
out_rtc:
- free_irq(chip->irq_base + MAX8925_IRQ_RTC_ALARM0, info);
+ free_irq(info->irq, info);
out_irq:
kfree(info);
return ret;
@@ -281,7 +285,7 @@ static int __devexit max8925_rtc_remove(struct platform_device *pdev)
struct max8925_rtc_info *info = platform_get_drvdata(pdev);
if (info) {
- free_irq(info->chip->irq_base + MAX8925_IRQ_RTC_ALARM0, info);
+ free_irq(info->irq, info);
rtc_device_unregister(info->rtc_dev);
kfree(info);
}
--
1.5.6.5
^ permalink raw reply related [flat|nested] 52+ messages in thread
* [PATCH 11/14] power_supply: max8925: use platform_data from cell
[not found] <2011041801>
` (10 preceding siblings ...)
2011-04-18 14:04 ` [PATCH 10/14] rtc: avoid to use hardcoding irq number in max8925 Haojian Zhuang
@ 2011-04-18 14:04 ` Haojian Zhuang
2011-04-18 21:49 ` Anton Vorontsov
2011-04-18 14:04 ` [PATCH 12/14] regulator: max8925: enable i2c sequence for control Haojian Zhuang
` (2 subsequent siblings)
14 siblings, 1 reply; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-18 14:04 UTC (permalink / raw)
To: sameo, haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo,
johnpol, cbou, dwmw2, lrg, broonie
Cc: Haojian Zhuang
Avoid to get platform_data from parent device. Get it from mfd cell
device instead.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Cc: Anton Vorontsov <cbou@mail.ru>
Cc: David Woodhouse <dwmw2@infradead.org>
---
drivers/power/max8925_power.c | 10 ++--------
1 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/power/max8925_power.c b/drivers/power/max8925_power.c
index 8e5aec2..a70e16d 100644
--- a/drivers/power/max8925_power.c
+++ b/drivers/power/max8925_power.c
@@ -425,16 +425,11 @@ static __devexit int max8925_deinit_charger(struct max8925_power_info *info)
static __devinit int max8925_power_probe(struct platform_device *pdev)
{
struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
- struct max8925_platform_data *max8925_pdata;
struct max8925_power_pdata *pdata = NULL;
struct max8925_power_info *info;
int ret;
- if (pdev->dev.parent->platform_data) {
- max8925_pdata = pdev->dev.parent->platform_data;
- pdata = max8925_pdata->power;
- }
-
+ pdata = pdev->dev.platform_data;
if (!pdata) {
dev_err(&pdev->dev, "platform data isn't assigned to "
"power supply\n");
@@ -447,6 +442,7 @@ static __devinit int max8925_power_probe(struct platform_device *pdev)
info->chip = chip;
info->gpm = chip->i2c;
info->adc = chip->adc;
+ platform_set_drvdata(pdev, info);
info->ac.name = "max8925-ac";
info->ac.type = POWER_SUPPLY_TYPE_MAINS;
@@ -482,8 +478,6 @@ static __devinit int max8925_power_probe(struct platform_device *pdev)
info->topoff_threshold = pdata->topoff_threshold;
info->fast_charge = pdata->fast_charge;
info->set_charger = pdata->set_charger;
- dev_set_drvdata(&pdev->dev, info);
- platform_set_drvdata(pdev, info);
max8925_init_charger(chip, info);
return 0;
--
1.5.6.5
^ permalink raw reply related [flat|nested] 52+ messages in thread
* [PATCH 12/14] regulator: max8925: enable i2c sequence for control
[not found] <2011041801>
` (11 preceding siblings ...)
2011-04-18 14:04 ` [PATCH 11/14] power_supply: max8925: use platform_data from cell Haojian Zhuang
@ 2011-04-18 14:04 ` Haojian Zhuang
2011-04-18 14:27 ` Mark Brown
2011-05-02 15:16 ` Samuel Ortiz
2011-04-18 14:04 ` [PATCH 13/14] regulator: check name in initialization of max8925 Haojian Zhuang
2011-04-18 14:04 ` [PATCH 14/14] regulator: 88pm8607: avoid to use constraint name in driver Haojian Zhuang
14 siblings, 2 replies; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-18 14:04 UTC (permalink / raw)
To: sameo, haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo,
johnpol, cbou, dwmw2, lrg, broonie
Cc: Haojian Zhuang
Force to enable i2c as power up/down sequence. Otherwise, SD/LDO can't
be enabled or disabled via accessing i2c bus.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Cc: Liam Girdwood <lrg@slimlogic.co.uk>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/regulator/max8925-regulator.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/regulator/max8925-regulator.c b/drivers/regulator/max8925-regulator.c
index 8ae1475..e4dbd66 100644
--- a/drivers/regulator/max8925-regulator.c
+++ b/drivers/regulator/max8925-regulator.c
@@ -23,6 +23,10 @@
#define SD1_DVM_SHIFT 5 /* SDCTL1 bit5 */
#define SD1_DVM_EN 6 /* SDV1 bit 6 */
+/* bit definitions in SD & LDO control registers */
+#define OUT_ENABLE 0x1f /* Power U/D sequence as I2C */
+#define OUT_DISABLE 0x1e /* Power U/D sequence as I2C */
+
struct max8925_regulator_info {
struct regulator_desc desc;
struct regulator_dev *regulator;
@@ -93,8 +97,8 @@ static int max8925_enable(struct regulator_dev *rdev)
struct max8925_regulator_info *info = rdev_get_drvdata(rdev);
return max8925_set_bits(info->i2c, info->enable_reg,
- 1 << info->enable_bit,
- 1 << info->enable_bit);
+ OUT_ENABLE << info->enable_bit,
+ OUT_ENABLE << info->enable_bit);
}
static int max8925_disable(struct regulator_dev *rdev)
@@ -102,7 +106,8 @@ static int max8925_disable(struct regulator_dev *rdev)
struct max8925_regulator_info *info = rdev_get_drvdata(rdev);
return max8925_set_bits(info->i2c, info->enable_reg,
- 1 << info->enable_bit, 0);
+ OUT_ENABLE << info->enable_bit,
+ OUT_DISABLE << info->enable_bit);
}
static int max8925_is_enabled(struct regulator_dev *rdev)
--
1.5.6.5
^ permalink raw reply related [flat|nested] 52+ messages in thread
* [PATCH 13/14] regulator: check name in initialization of max8925
[not found] <2011041801>
` (12 preceding siblings ...)
2011-04-18 14:04 ` [PATCH 12/14] regulator: max8925: enable i2c sequence for control Haojian Zhuang
@ 2011-04-18 14:04 ` Haojian Zhuang
2011-04-18 14:28 ` Mark Brown
2011-04-20 11:55 ` [PATCH 13/14] regulator: max8925: fix not add device if missing init data Haojian Zhuang
2011-04-18 14:04 ` [PATCH 14/14] regulator: 88pm8607: avoid to use constraint name in driver Haojian Zhuang
14 siblings, 2 replies; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-18 14:04 UTC (permalink / raw)
To: sameo, haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo,
johnpol, cbou, dwmw2, lrg, broonie
Cc: Haojian Zhuang
Check name in initialization of max8925 regulator driver.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Cc: Liam Girdwood <lrg@slimlogic.co.uk>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/regulator/max8925-regulator.c | 39 ++++++++++++++++-----------------
1 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/drivers/regulator/max8925-regulator.c b/drivers/regulator/max8925-regulator.c
index e4dbd66..7ce8147 100644
--- a/drivers/regulator/max8925-regulator.c
+++ b/drivers/regulator/max8925-regulator.c
@@ -174,7 +174,7 @@ static struct regulator_ops max8925_regulator_ldo_ops = {
#define MAX8925_SDV(_id, min, max, step) \
{ \
.desc = { \
- .name = "SDV" #_id, \
+ .name = "SD" #_id, \
.ops = &max8925_regulator_sdv_ops, \
.type = REGULATOR_VOLTAGE, \
.id = MAX8925_ID_SD##_id, \
@@ -236,39 +236,38 @@ static struct max8925_regulator_info max8925_regulator_info[] = {
MAX8925_LDO(20, 750, 3900, 50),
};
-static struct max8925_regulator_info * __devinit find_regulator_info(int id)
+static int __devinit max8925_regulator_probe(struct platform_device *pdev)
{
- struct max8925_regulator_info *ri;
+ struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
+ struct max8925_regulator_info *ri = NULL;
+ struct regulator_init_data *pdata;
+ struct regulator_dev *rdev;
int i;
+ pdata = pdev->dev.platform_data;
+ if ((pdata == NULL) || (pdata->driver_data == NULL))
+ return -EINVAL;
+
for (i = 0; i < ARRAY_SIZE(max8925_regulator_info); i++) {
ri = &max8925_regulator_info[i];
- if (ri->desc.id == id)
- return ri;
+ /* pdata->driver_data stores the name of regulator */
+ if (!strcmp(ri->desc.name, pdata->driver_data))
+ break;
}
- return NULL;
-}
-
-static int __devinit max8925_regulator_probe(struct platform_device *pdev)
-{
- struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
- struct max8925_platform_data *pdata = chip->dev->platform_data;
- struct max8925_regulator_info *ri;
- struct regulator_dev *rdev;
-
- ri = find_regulator_info(pdev->id);
- if (ri == NULL) {
- dev_err(&pdev->dev, "invalid regulator ID specified\n");
+ if (i > ARRAY_SIZE(max8925_regulator_info)) {
+ dev_err(&pdev->dev, "Failed to find regulator %s\n",
+ pdata->constraints.name);
return -EINVAL;
}
ri->i2c = chip->i2c;
ri->chip = chip;
+ /* replace driver_data with ri */
rdev = regulator_register(&ri->desc, &pdev->dev,
- pdata->regulator[pdev->id], ri);
+ pdata, ri);
if (IS_ERR(rdev)) {
dev_err(&pdev->dev, "failed to register regulator %s\n",
- ri->desc.name);
+ ri->desc.name);
return PTR_ERR(rdev);
}
--
1.5.6.5
^ permalink raw reply related [flat|nested] 52+ messages in thread
* [PATCH 14/14] regulator: 88pm8607: avoid to use constraint name in driver
[not found] <2011041801>
` (13 preceding siblings ...)
2011-04-18 14:04 ` [PATCH 13/14] regulator: check name in initialization of max8925 Haojian Zhuang
@ 2011-04-18 14:04 ` Haojian Zhuang
2011-04-18 14:30 ` Mark Brown
2011-04-20 11:56 ` Haojian Zhuang
14 siblings, 2 replies; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-18 14:04 UTC (permalink / raw)
To: sameo, haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo,
johnpol, cbou, dwmw2, lrg, broonie
Cc: Haojian Zhuang
Avoid to use constraint name in driver. So use driver_data instead to
store regulator name in platform driver.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Cc: Liam Girdwood <lrg@slimlogic.co.uk>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/regulator/88pm8607.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index 784ea77..63fc34e 100644
--- a/drivers/regulator/88pm8607.c
+++ b/drivers/regulator/88pm8607.c
@@ -402,12 +402,13 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
int i;
pdata = pdev->dev.platform_data;
- if (pdata == NULL)
+ if ((pdata == NULL) || (pdata->driver_data == NULL))
return -EINVAL;
for (i = 0; i < ARRAY_SIZE(pm8607_regulator_info); i++) {
info = &pm8607_regulator_info[i];
- if (!strcmp(info->desc.name, pdata->constraints.name))
+ /* pdata->driver_data stores the name of regulator */
+ if (!strcmp(info->desc.name, pdata->driver_data))
break;
}
if (i > ARRAY_SIZE(pm8607_regulator_info)) {
@@ -424,6 +425,7 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
if (info->chip->buck3_double)
info->slope_double = 1;
+ /* replace driver_data with info */
info->regulator = regulator_register(&info->desc, &pdev->dev,
pdata, info);
if (IS_ERR(info->regulator)) {
--
1.5.6.5
^ permalink raw reply related [flat|nested] 52+ messages in thread
* Re: [PATCH 12/14] regulator: max8925: enable i2c sequence for control
2011-04-18 14:04 ` [PATCH 12/14] regulator: max8925: enable i2c sequence for control Haojian Zhuang
@ 2011-04-18 14:27 ` Mark Brown
2011-05-02 15:16 ` Samuel Ortiz
1 sibling, 0 replies; 52+ messages in thread
From: Mark Brown @ 2011-04-18 14:27 UTC (permalink / raw)
To: Haojian Zhuang
Cc: sameo, haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo,
johnpol, cbou, dwmw2, lrg
On Mon, Apr 18, 2011 at 10:04:09PM +0800, Haojian Zhuang wrote:
> Force to enable i2c as power up/down sequence. Otherwise, SD/LDO can't
> be enabled or disabled via accessing i2c bus.
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
but please work on the quality of your changelogs.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 13/14] regulator: check name in initialization of max8925
2011-04-18 14:04 ` [PATCH 13/14] regulator: check name in initialization of max8925 Haojian Zhuang
@ 2011-04-18 14:28 ` Mark Brown
2011-04-18 15:33 ` Haojian Zhuang
2011-04-20 11:55 ` [PATCH 13/14] regulator: max8925: fix not add device if missing init data Haojian Zhuang
1 sibling, 1 reply; 52+ messages in thread
From: Mark Brown @ 2011-04-18 14:28 UTC (permalink / raw)
To: Haojian Zhuang
Cc: sameo, haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo,
johnpol, cbou, dwmw2, lrg
On Mon, Apr 18, 2011 at 10:04:10PM +0800, Haojian Zhuang wrote:
> Check name in initialization of max8925 regulator driver.
What name are we checking and why do we need to check it? I've no idea
what the patch is supposed to do which makes it hard to review.
> +++ b/drivers/regulator/max8925-regulator.c
> @@ -174,7 +174,7 @@ static struct regulator_ops max8925_regulator_ldo_ops = {
> #define MAX8925_SDV(_id, min, max, step) \
> { \
> .desc = { \
> - .name = "SDV" #_id, \
> + .name = "SD" #_id, \
The above isn't obviously correct - it changes the name that's assigned
from matching the macro used to something different.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 14/14] regulator: 88pm8607: avoid to use constraint name in driver
2011-04-18 14:04 ` [PATCH 14/14] regulator: 88pm8607: avoid to use constraint name in driver Haojian Zhuang
@ 2011-04-18 14:30 ` Mark Brown
2011-04-18 15:38 ` Haojian Zhuang
2011-04-20 11:56 ` Haojian Zhuang
1 sibling, 1 reply; 52+ messages in thread
From: Mark Brown @ 2011-04-18 14:30 UTC (permalink / raw)
To: Haojian Zhuang
Cc: sameo, haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo,
johnpol, cbou, dwmw2, lrg
On Mon, Apr 18, 2011 at 10:04:11PM +0800, Haojian Zhuang wrote:
> Avoid to use constraint name in driver. So use driver_data instead to
> store regulator name in platform driver.
If this is something that's present in the current driver it should be
fixed for 2.6.39 so should be a patch at the start of the series which
can be applied separately to the others.
> + /* pdata->driver_data stores the name of regulator */
> + if (!strcmp(info->desc.name, pdata->driver_data))
> break;
Why not just use #defines in the header? It'd be less error prone if
nothing else.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 13/14] regulator: check name in initialization of max8925
2011-04-18 14:28 ` Mark Brown
@ 2011-04-18 15:33 ` Haojian Zhuang
2011-04-18 16:04 ` Mark Brown
0 siblings, 1 reply; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-18 15:33 UTC (permalink / raw)
To: Mark Brown
Cc: Haojian Zhuang, sameo, linux-kernel, dmitry.torokhov, a.zummo,
johnpol, cbou, dwmw2, lrg
On Mon, Apr 18, 2011 at 10:28 PM, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:
> On Mon, Apr 18, 2011 at 10:04:10PM +0800, Haojian Zhuang wrote:
>> Check name in initialization of max8925 regulator driver.
>
> What name are we checking and why do we need to check it? I've no idea
> what the patch is supposed to do which makes it hard to review.
>
Actually, I didn't submit any platform driver before. So I can't
attach the related patch on
platform driver. After 2.6.39, I'll upload patches on platform driver.
In this original design, regulator data is assigned in platform driver
separately with index.
If I missed to define regulator[0] in platform data, the regulator
driver will meet failure
because of checking in max8925-core.c. The regulator[0] always means Buck0.
So I want to avoid to use the index and check regulator[] one by one.
I use a pointer to link
all regulator data together. I just need to check whether the
regulator pointer is valid or not.
>> +++ b/drivers/regulator/max8925-regulator.c
>> @@ -174,7 +174,7 @@ static struct regulator_ops max8925_regulator_ldo_ops = {
>> #define MAX8925_SDV(_id, min, max, step) \
>> { \
>> .desc = { \
>> - .name = "SDV" #_id, \
>> + .name = "SD" #_id, \
>
> The above isn't obviously correct - it changes the name that's assigned
> from matching the macro used to something different.
>
The name isn't used by others. So I change it to SDx in order to
compare regulator name.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 14/14] regulator: 88pm8607: avoid to use constraint name in driver
2011-04-18 14:30 ` Mark Brown
@ 2011-04-18 15:38 ` Haojian Zhuang
2011-04-18 16:02 ` Mark Brown
0 siblings, 1 reply; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-18 15:38 UTC (permalink / raw)
To: Mark Brown
Cc: Haojian Zhuang, sameo, linux-kernel, dmitry.torokhov, a.zummo,
johnpol, cbou, dwmw2, lrg
On Mon, Apr 18, 2011 at 10:30 PM, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:
> On Mon, Apr 18, 2011 at 10:04:11PM +0800, Haojian Zhuang wrote:
>> Avoid to use constraint name in driver. So use driver_data instead to
>> store regulator name in platform driver.
>
> If this is something that's present in the current driver it should be
> fixed for 2.6.39 so should be a patch at the start of the series which
> can be applied separately to the others.
>
>> + /* pdata->driver_data stores the name of regulator */
>> + if (!strcmp(info->desc.name, pdata->driver_data))
>> break;
>
> Why not just use #defines in the header? It'd be less error prone if
> nothing else.
>
I don't understand this. desc.name is assigned in regulator driver.
pdata->driver_data is assigned in platform driver. I need to use same
name to link them together.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 14/14] regulator: 88pm8607: avoid to use constraint name in driver
2011-04-18 15:38 ` Haojian Zhuang
@ 2011-04-18 16:02 ` Mark Brown
2011-04-19 2:45 ` Haojian Zhuang
0 siblings, 1 reply; 52+ messages in thread
From: Mark Brown @ 2011-04-18 16:02 UTC (permalink / raw)
To: Haojian Zhuang
Cc: Haojian Zhuang, sameo, linux-kernel, dmitry.torokhov, a.zummo,
johnpol, cbou, dwmw2, lrg
On Mon, Apr 18, 2011 at 11:38:00PM +0800, Haojian Zhuang wrote:
> On Mon, Apr 18, 2011 at 10:30 PM, Mark Brown
> > Why not just use #defines in the header? It'd be less error prone if
> > nothing else.
> I don't understand this. desc.name is assigned in regulator driver.
> pdata->driver_data is assigned in platform driver. I need to use same
> name to link them together.
I assume that by "platform driver" you mean the machine driver for the
system? What I'm saying is that instead of using a string to match it'd
be more normal to use an enum in the driver header, that way if someone
typos the string or something then there will be a build failure whereas
with strings like this there will only be a runtime failure.
Part of the problem here is that your changelogs aren't really saying
why you're making these changes...
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 13/14] regulator: check name in initialization of max8925
2011-04-18 15:33 ` Haojian Zhuang
@ 2011-04-18 16:04 ` Mark Brown
2011-04-19 2:42 ` Haojian Zhuang
0 siblings, 1 reply; 52+ messages in thread
From: Mark Brown @ 2011-04-18 16:04 UTC (permalink / raw)
To: Haojian Zhuang
Cc: Haojian Zhuang, sameo, linux-kernel, dmitry.torokhov, a.zummo,
johnpol, cbou, dwmw2, lrg
On Mon, Apr 18, 2011 at 11:33:34PM +0800, Haojian Zhuang wrote:
> So I want to avoid to use the index and check regulator[] one by one.
> I use a pointer to link
> all regulator data together. I just need to check whether the
> regulator pointer is valid or not.
Why? I don't understand what the goal of this change is.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 11/14] power_supply: max8925: use platform_data from cell
2011-04-18 14:04 ` [PATCH 11/14] power_supply: max8925: use platform_data from cell Haojian Zhuang
@ 2011-04-18 21:49 ` Anton Vorontsov
2011-05-02 15:15 ` Samuel Ortiz
0 siblings, 1 reply; 52+ messages in thread
From: Anton Vorontsov @ 2011-04-18 21:49 UTC (permalink / raw)
To: Haojian Zhuang
Cc: sameo, haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo,
johnpol, dwmw2, lrg, broonie
On Mon, Apr 18, 2011 at 10:04:08PM +0800, Haojian Zhuang wrote:
> Avoid to get platform_data from parent device. Get it from mfd cell
> device instead.
>
> Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
> Cc: Anton Vorontsov <cbou@mail.ru>
> Cc: David Woodhouse <dwmw2@infradead.org>
> ---
Acked-by: Anton Vorontsov <cbouatmailru@gmail.com>
Thanks,
--
Anton Vorontsov
Email: cbouatmailru@gmail.com
^ permalink raw reply [flat|nested] 52+ messages in thread
* RE: [PATCH 13/14] regulator: check name in initialization of max8925
2011-04-18 16:04 ` Mark Brown
@ 2011-04-19 2:42 ` Haojian Zhuang
2011-04-19 8:09 ` Mark Brown
0 siblings, 1 reply; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-19 2:42 UTC (permalink / raw)
To: Mark Brown, Haojian Zhuang
Cc: sameo@linux.intel.com, linux-kernel@vger.kernel.org,
dmitry.torokhov@gmail.com, a.zummo@towertech.it,
johnpol@2ka.mipt.ru, cbou@mail.ru, dwmw2@infradead.org,
lrg@slimlogic.co.uk
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb2312", Size: 1549 bytes --]
>-----Original Message-----
>From: Mark Brown [mailto:broonie@opensource.wolfsonmicro.com]
>Sent: 2011Äê4ÔÂ19ÈÕ 12:04 AM
>To: Haojian Zhuang
>Cc: Haojian Zhuang; sameo@linux.intel.com; linux-kernel@vger.kernel.org;
>dmitry.torokhov@gmail.com; a.zummo@towertech.it; johnpol@2ka.mipt.ru;
>cbou@mail.ru; dwmw2@infradead.org; lrg@slimlogic.co.uk
>Subject: Re: [PATCH 13/14] regulator: check name in initialization of
>max8925
>
>On Mon, Apr 18, 2011 at 11:33:34PM +0800, Haojian Zhuang wrote:
>
>> So I want to avoid to use the index and check regulator[] one by one.
>> I use a pointer to link
>> all regulator data together. I just need to check whether the
>> regulator pointer is valid or not.
>
>Why? I don't understand what the goal of this change is.
Original implementation:
Max8925_core.c:
If ((pdata == NULL) || (pdata->regulator[0] == NULL))
Return -EINVAL;
Machine driver:
Platform data:
.regulator[0] = xxx
.regulator[1] = xxx
The index of regulator array is id of buck and ldo.
There's issue in max8925_core.c since we can't assume regulator[0] always declared in machine driver.
Current implementation:
Max8925_core.c:
If ((pdata == NULL) || (pdata->regulator == NULL))
Return -EINVAL;
Machine driver:
Platform data:
Use two parameters: num_regulators and regulator pointer. The index of new regulator array isn't id of buck and ldo any more.
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 52+ messages in thread
* RE: [PATCH 14/14] regulator: 88pm8607: avoid to use constraint name in driver
2011-04-18 16:02 ` Mark Brown
@ 2011-04-19 2:45 ` Haojian Zhuang
2011-04-19 8:13 ` Mark Brown
0 siblings, 1 reply; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-19 2:45 UTC (permalink / raw)
To: Mark Brown, Haojian Zhuang
Cc: sameo@linux.intel.com, linux-kernel@vger.kernel.org,
dmitry.torokhov@gmail.com, a.zummo@towertech.it,
johnpol@2ka.mipt.ru, cbou@mail.ru, dwmw2@infradead.org,
lrg@slimlogic.co.uk
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1759 bytes --]
>-----Original Message-----
>From: Mark Brown [mailto:broonie@opensource.wolfsonmicro.com]
>Sent: 2011å¹´4æ19æ¥ 12:03 AM
>To: Haojian Zhuang
>Cc: Haojian Zhuang; sameo@linux.intel.com; linux-kernel@vger.kernel.org;
>dmitry.torokhov@gmail.com; a.zummo@towertech.it; johnpol@2ka.mipt.ru;
>cbou@mail.ru; dwmw2@infradead.org; lrg@slimlogic.co.uk
>Subject: Re: [PATCH 14/14] regulator: 88pm8607: avoid to use constraint
>name in driver
>
>On Mon, Apr 18, 2011 at 11:38:00PM +0800, Haojian Zhuang wrote:
>> On Mon, Apr 18, 2011 at 10:30 PM, Mark Brown
>
>> > Why not just use #defines in the header? Â It'd be less error prone
>if
>> > nothing else.
>
>> I don't understand this. desc.name is assigned in regulator driver.
>> pdata->driver_data is assigned in platform driver. I need to use same
>> name to link them together.
>
>I assume that by "platform driver" you mean the machine driver for the
>system? What I'm saying is that instead of using a string to match it'd
>be more normal to use an enum in the driver header, that way if someone
>typos the string or something then there will be a build failure whereas
>with strings like this there will only be a runtime failure.
>
It's nearly same whatever it's string or index number. In machine driver,
it's more convenient on using string. Otherwise, I still need to create
a new integer array to store index since I transfer them into regulator data
by driver_data parameter in regulator_init_data.
>Part of the problem here is that your changelogs aren't really saying
>why you're making these changes...
Yes, the changelog is too simple.
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 13/14] regulator: check name in initialization of max8925
2011-04-19 2:42 ` Haojian Zhuang
@ 2011-04-19 8:09 ` Mark Brown
2011-04-19 8:28 ` Haojian Zhuang
0 siblings, 1 reply; 52+ messages in thread
From: Mark Brown @ 2011-04-19 8:09 UTC (permalink / raw)
To: Haojian Zhuang
Cc: Haojian Zhuang, sameo@linux.intel.com,
linux-kernel@vger.kernel.org, dmitry.torokhov@gmail.com,
a.zummo@towertech.it, johnpol@2ka.mipt.ru, cbou@mail.ru,
dwmw2@infradead.org, lrg@slimlogic.co.uk
On Mon, Apr 18, 2011 at 07:42:09PM -0700, Haojian Zhuang wrote:
> Machine driver:
> Platform data:
> .regulator[0] = xxx
> .regulator[1] = xxx
> The index of regulator array is id of buck and ldo.
> There's issue in max8925_core.c since we can't assume regulator[0] always declared in machine driver.
What is the issue? It's trivial to skip the regulator if the data is
null.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 14/14] regulator: 88pm8607: avoid to use constraint name in driver
2011-04-19 2:45 ` Haojian Zhuang
@ 2011-04-19 8:13 ` Mark Brown
2011-04-19 11:34 ` Haojian Zhuang
0 siblings, 1 reply; 52+ messages in thread
From: Mark Brown @ 2011-04-19 8:13 UTC (permalink / raw)
To: Haojian Zhuang
Cc: Haojian Zhuang, sameo@linux.intel.com,
linux-kernel@vger.kernel.org, dmitry.torokhov@gmail.com,
a.zummo@towertech.it, johnpol@2ka.mipt.ru, cbou@mail.ru,
dwmw2@infradead.org, lrg@slimlogic.co.uk
On Mon, Apr 18, 2011 at 07:45:06PM -0700, Haojian Zhuang wrote:
> >I assume that by "platform driver" you mean the machine driver for the
> >system? What I'm saying is that instead of using a string to match it'd
> >be more normal to use an enum in the driver header, that way if someone
> >typos the string or something then there will be a build failure whereas
> >with strings like this there will only be a runtime failure.
> It's nearly same whatever it's string or index number. In machine driver,
> it's more convenient on using string. Otherwise, I still need to create
You're saying it's more convenient but you're not saying why. I'd say
that the lack of build time checking I mentioned is actually unhelpful.
> a new integer array to store index since I transfer them into regulator data
> by driver_data parameter in regulator_init_data.
You already need to add a char * to store the name, adding an enum
instead isn't a substantial difference...
^ permalink raw reply [flat|nested] 52+ messages in thread
* RE: [PATCH 13/14] regulator: check name in initialization of max8925
2011-04-19 8:09 ` Mark Brown
@ 2011-04-19 8:28 ` Haojian Zhuang
2011-04-19 10:51 ` Mark Brown
0 siblings, 1 reply; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-19 8:28 UTC (permalink / raw)
To: Mark Brown
Cc: Haojian Zhuang, sameo@linux.intel.com,
linux-kernel@vger.kernel.org, dmitry.torokhov@gmail.com,
a.zummo@towertech.it, johnpol@2ka.mipt.ru, cbou@mail.ru,
dwmw2@infradead.org, lrg@slimlogic.co.uk
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb2312", Size: 1112 bytes --]
>-----Original Message-----
>From: Mark Brown [mailto:broonie@opensource.wolfsonmicro.com]
>Sent: 2011Äê4ÔÂ19ÈÕ 4:09 PM
>To: Haojian Zhuang
>Cc: Haojian Zhuang; sameo@linux.intel.com; linux-kernel@vger.kernel.org;
>dmitry.torokhov@gmail.com; a.zummo@towertech.it; johnpol@2ka.mipt.ru;
>cbou@mail.ru; dwmw2@infradead.org; lrg@slimlogic.co.uk
>Subject: Re: [PATCH 13/14] regulator: check name in initialization of
>max8925
>
>On Mon, Apr 18, 2011 at 07:42:09PM -0700, Haojian Zhuang wrote:
>> Machine driver:
>> Platform data:
>> .regulator[0] = xxx
>> .regulator[1] = xxx
>
>> The index of regulator array is id of buck and ldo.
>> There's issue in max8925_core.c since we can't assume regulator[0]
>always declared in machine driver.
>
>What is the issue? It's trivial to skip the regulator if the data is
>null.
It skiped all regulators if regulator[0] isn't decleared.
(pdata == NULL) || (pdata->regulator[0] == NULL)
So it's a bug.
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 13/14] regulator: check name in initialization of max8925
2011-04-19 8:28 ` Haojian Zhuang
@ 2011-04-19 10:51 ` Mark Brown
2011-04-19 11:33 ` Haojian Zhuang
0 siblings, 1 reply; 52+ messages in thread
From: Mark Brown @ 2011-04-19 10:51 UTC (permalink / raw)
To: Haojian Zhuang
Cc: Haojian Zhuang, sameo@linux.intel.com,
linux-kernel@vger.kernel.org, dmitry.torokhov@gmail.com,
a.zummo@towertech.it, johnpol@2ka.mipt.ru, cbou@mail.ru,
dwmw2@infradead.org, lrg@slimlogic.co.uk
On Tue, Apr 19, 2011 at 01:28:23AM -0700, Haojian Zhuang wrote:
> >> There's issue in max8925_core.c since we can't assume regulator[0]
> >always declared in machine driver.
> >What is the issue? It's trivial to skip the regulator if the data is
> >null.
> It skiped all regulators if regulator[0] isn't decleared.
> (pdata == NULL) || (pdata->regulator[0] == NULL)
> So it's a bug.
Surely the obvious fix is to fix the issue and not skip all the
regulators if an individual regulator has no data?
^ permalink raw reply [flat|nested] 52+ messages in thread
* RE: [PATCH 13/14] regulator: check name in initialization of max8925
2011-04-19 10:51 ` Mark Brown
@ 2011-04-19 11:33 ` Haojian Zhuang
0 siblings, 0 replies; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-19 11:33 UTC (permalink / raw)
To: Mark Brown
Cc: Haojian Zhuang, sameo@linux.intel.com,
linux-kernel@vger.kernel.org, dmitry.torokhov@gmail.com,
a.zummo@towertech.it, johnpol@2ka.mipt.ru, cbou@mail.ru,
dwmw2@infradead.org, lrg@slimlogic.co.uk
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb2312", Size: 1112 bytes --]
>-----Original Message-----
>From: Mark Brown [mailto:broonie@opensource.wolfsonmicro.com]
>Sent: 2011Äê4ÔÂ19ÈÕ 6:51 PM
>To: Haojian Zhuang
>Cc: Haojian Zhuang; sameo@linux.intel.com; linux-kernel@vger.kernel.org;
>dmitry.torokhov@gmail.com; a.zummo@towertech.it; johnpol@2ka.mipt.ru;
>cbou@mail.ru; dwmw2@infradead.org; lrg@slimlogic.co.uk
>Subject: Re: [PATCH 13/14] regulator: check name in initialization of
>max8925
>
>On Tue, Apr 19, 2011 at 01:28:23AM -0700, Haojian Zhuang wrote:
>
>> >> There's issue in max8925_core.c since we can't assume regulator[0]
>> >always declared in machine driver.
>
>> >What is the issue? It's trivial to skip the regulator if the data is
>> >null.
>
>> It skiped all regulators if regulator[0] isn't decleared.
>> (pdata == NULL) || (pdata->regulator[0] == NULL)
>
>> So it's a bug.
>
>Surely the obvious fix is to fix the issue and not skip all the
>regulators if an individual regulator has no data?
Yes.
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 52+ messages in thread
* RE: [PATCH 14/14] regulator: 88pm8607: avoid to use constraint name in driver
2011-04-19 8:13 ` Mark Brown
@ 2011-04-19 11:34 ` Haojian Zhuang
0 siblings, 0 replies; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-19 11:34 UTC (permalink / raw)
To: Mark Brown
Cc: Haojian Zhuang, sameo@linux.intel.com,
linux-kernel@vger.kernel.org, dmitry.torokhov@gmail.com,
a.zummo@towertech.it, johnpol@2ka.mipt.ru, cbou@mail.ru,
dwmw2@infradead.org, lrg@slimlogic.co.uk
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb2312", Size: 1673 bytes --]
>-----Original Message-----
>From: Mark Brown [mailto:broonie@opensource.wolfsonmicro.com]
>Sent: 2011Äê4ÔÂ19ÈÕ 4:13 PM
>To: Haojian Zhuang
>Cc: Haojian Zhuang; sameo@linux.intel.com; linux-kernel@vger.kernel.org;
>dmitry.torokhov@gmail.com; a.zummo@towertech.it; johnpol@2ka.mipt.ru;
>cbou@mail.ru; dwmw2@infradead.org; lrg@slimlogic.co.uk
>Subject: Re: [PATCH 14/14] regulator: 88pm8607: avoid to use constraint
>name in driver
>
>On Mon, Apr 18, 2011 at 07:45:06PM -0700, Haojian Zhuang wrote:
>
>> >I assume that by "platform driver" you mean the machine driver for
>the
>> >system? What I'm saying is that instead of using a string to match
>it'd
>> >be more normal to use an enum in the driver header, that way if
>someone
>> >typos the string or something then there will be a build failure
>whereas
>> >with strings like this there will only be a runtime failure.
>
>> It's nearly same whatever it's string or index number. In machine
>driver,
>> it's more convenient on using string. Otherwise, I still need to
>create
>
>You're saying it's more convenient but you're not saying why. I'd say
>that the lack of build time checking I mentioned is actually unhelpful.
>
>> a new integer array to store index since I transfer them into
>regulator data
>> by driver_data parameter in regulator_init_data.
>
>You already need to add a char * to store the name, adding an enum
>instead isn't a substantial difference...
OK. So I just need to switch to ID instead of name on these two patches.
Is it right?
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH 08/14] mfd: use platform_data in max8925
2011-04-18 14:04 ` [PATCH 08/14] mfd: use platform_data in max8925 Haojian Zhuang
@ 2011-04-20 11:54 ` Haojian Zhuang
2011-04-26 9:45 ` Samuel Ortiz
0 siblings, 1 reply; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-20 11:54 UTC (permalink / raw)
To: sameo, haojian.zhuang, linux-kernel, lrg, broonie; +Cc: Haojian Zhuang
Use platform_data to pass parameters to client driver.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
---
drivers/mfd/max8925-core.c | 287 +++++++++++++++++++++++++-------------------
1 files changed, 162 insertions(+), 125 deletions(-)
diff --git a/drivers/mfd/max8925-core.c b/drivers/mfd/max8925-core.c
index 58cc5fd..a974711 100644
--- a/drivers/mfd/max8925-core.c
+++ b/drivers/mfd/max8925-core.c
@@ -17,102 +17,88 @@
#include <linux/platform_device.h>
#include <linux/mfd/core.h>
#include <linux/mfd/max8925.h>
+#include <linux/regulator/machine.h>
-static struct resource backlight_resources[] = {
- {
- .name = "max8925-backlight",
- .start = MAX8925_WLED_MODE_CNTL,
- .end = MAX8925_WLED_CNTL,
- .flags = IORESOURCE_IO,
- },
+static struct resource bk_resources[] __devinitdata = {
+ {0, 0, "max8925-backlight", IORESOURCE_IO,},
};
-static struct mfd_cell backlight_devs[] = {
- {
- .name = "max8925-backlight",
- .num_resources = 1,
- .resources = &backlight_resources[0],
- .id = -1,
- },
+static struct resource touch_resources[] __devinitdata = {
+ {MAX8925_IRQ_TSC_STICK, MAX8925_IRQ_TSC_STICK, "touch stick",
+ IORESOURCE_IRQ,},
+ {MAX8925_IRQ_TSC_NSTICK, MAX8925_IRQ_TSC_NSTICK, "touch nstick",
+ IORESOURCE_IRQ,},
};
-static struct resource touch_resources[] = {
- {
- .name = "max8925-tsc",
- .start = MAX8925_TSC_IRQ,
- .end = MAX8925_ADC_RES_END,
- .flags = IORESOURCE_IO,
- },
+static struct resource power_resources[] __devinitdata = {
+ {MAX8925_IRQ_VCHG_DC_OVP, MAX8925_IRQ_VCHG_DC_OVP, \
+ "dc overvoltage", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_DC_F, MAX8925_IRQ_VCHG_DC_F, \
+ "dc falling", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_DC_R, MAX8925_IRQ_VCHG_DC_R, \
+ "dc rising", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_USB_OVP, MAX8925_IRQ_VCHG_USB_OVP, \
+ "usb overvoltage", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_USB_F, MAX8925_IRQ_VCHG_USB_F, \
+ "usb falling", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_USB_R, MAX8925_IRQ_VCHG_USB_R, \
+ "usb rising", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_THM_OK_R, MAX8925_IRQ_VCHG_THM_OK_R, \
+ "bat temp valid", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_THM_OK_F, MAX8925_IRQ_VCHG_THM_OK_F, \
+ "bat temp invalid", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_SYSLOW_F, MAX8925_IRQ_VCHG_SYSLOW_F, \
+ "VSYSLOW falling", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_SYSLOW_R, MAX8925_IRQ_VCHG_SYSLOW_R, \
+ "VSYSLOW rising", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_RST, MAX8925_IRQ_VCHG_RST, \
+ "charger restart", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_DONE, MAX8925_IRQ_VCHG_DONE, \
+ "charger done", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_TOPOFF, MAX8925_IRQ_VCHG_TOPOFF, \
+ "charger topoff", IORESOURCE_IRQ,},
+ {MAX8925_IRQ_VCHG_TMR_FAULT, MAX8925_IRQ_VCHG_TMR_FAULT, \
+ "charger expire", IORESOURCE_IRQ,},
};
-static struct mfd_cell touch_devs[] = {
- {
- .name = "max8925-touch",
- .num_resources = 1,
- .resources = &touch_resources[0],
- .id = -1,
- },
+static struct resource rtc_resources[] __devinitdata = {
+ {MAX8925_IRQ_RTC_ALARM0, MAX8925_IRQ_RTC_ALARM0, "rtc-alarm0",
+ IORESOURCE_IRQ,},
+ {MAX8925_IRQ_RTC_ALARM1, MAX8925_IRQ_RTC_ALARM1, "rtc-alarm1",
+ IORESOURCE_IRQ,},
};
-static struct resource power_supply_resources[] = {
- {
- .name = "max8925-power",
- .start = MAX8925_CHG_IRQ1,
- .end = MAX8925_CHG_IRQ1_MASK,
- .flags = IORESOURCE_IO,
- },
+static struct resource onkey_resources[] __devinitdata = {
+ {MAX8925_IRQ_GPM_SW_R, MAX8925_IRQ_GPM_SW_R, "onkey R",
+ IORESOURCE_IRQ,},
+ {MAX8925_IRQ_GPM_SW_F, MAX8925_IRQ_GPM_SW_F, "onkey F",
+ IORESOURCE_IRQ,},
};
-static struct mfd_cell power_devs[] = {
- {
- .name = "max8925-power",
- .num_resources = 1,
- .resources = &power_supply_resources[0],
- .id = -1,
- },
+static struct mfd_cell bk_devs[] = {
+ {"max8925-backlight", -1,},
};
-static struct resource rtc_resources[] = {
- {
- .name = "max8925-rtc",
- .start = MAX8925_RTC_IRQ,
- .end = MAX8925_RTC_IRQ_MASK,
- .flags = IORESOURCE_IO,
- },
+static struct mfd_cell touch_devs[] = {
+ {"max8925-touch", -1,},
};
-static struct mfd_cell rtc_devs[] = {
- {
- .name = "max8925-rtc",
- .num_resources = 1,
- .resources = &rtc_resources[0],
- .id = -1,
- },
+static struct mfd_cell power_devs[] = {
+ {"max8925-power", -1,},
};
-static struct resource onkey_resources[] = {
- {
- .name = "max8925-onkey",
- .start = MAX8925_IRQ_GPM_SW_R,
- .end = MAX8925_IRQ_GPM_SW_R,
- .flags = IORESOURCE_IRQ,
- }, {
- .name = "max8925-onkey",
- .start = MAX8925_IRQ_GPM_SW_F,
- .end = MAX8925_IRQ_GPM_SW_F,
- .flags = IORESOURCE_IRQ,
- },
+static struct mfd_cell rtc_devs[] = {
+ {"max8925-rtc", -1,},
};
static struct mfd_cell onkey_devs[] = {
- {
- .name = "max8925-onkey",
- .num_resources = 2,
- .resources = &onkey_resources[0],
- .id = -1,
- },
+ {"max8925-onkey", -1,},
};
+static struct max8925_backlight_pdata bk_pdata;
+static struct max8925_touch_pdata touch_pdata;
+static struct max8925_power_pdata power_pdata;
+
#define MAX8925_REG_RESOURCE(_start, _end) \
{ \
.start = MAX8925_##_start, \
@@ -588,6 +574,101 @@ tsc_irq:
return 0;
}
+static void __devinit device_bk_init(struct max8925_chip *chip,
+ struct i2c_client *i2c,
+ struct max8925_platform_data *pdata)
+{
+ int ret;
+
+ if ((pdata == NULL) || (pdata->backlight == NULL))
+ return;
+
+ memcpy(&bk_pdata, pdata->backlight,
+ sizeof(struct max8925_backlight_pdata));
+ bk_devs[0].platform_data = &bk_pdata;
+ bk_devs[0].pdata_size = sizeof(bk_pdata);
+
+ bk_devs[0].num_resources = 1;
+ bk_devs[0].resources = &bk_resources[0];
+ ret = mfd_add_devices(chip->dev, 0, &bk_devs[0], 1,
+ &bk_resources[0], 0);
+ if (ret < 0)
+ dev_err(chip->dev, "Failed to add backlight subdev\n");
+}
+
+static void __devinit device_rtc_init(struct max8925_chip *chip,
+ struct i2c_client *i2c,
+ struct max8925_platform_data *pdata)
+{
+ int ret;
+
+ rtc_devs[0].num_resources = ARRAY_SIZE(rtc_resources);
+ rtc_devs[0].resources = &rtc_resources[0];
+ ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0], 1,
+ &rtc_resources[0], chip->irq_base);
+ if (ret < 0)
+ dev_err(chip->dev, "Failed to add rtc subdev\n");
+}
+
+static void __devinit device_touch_init(struct max8925_chip *chip,
+ struct i2c_client *i2c,
+ struct max8925_platform_data *pdata)
+{
+ int ret;
+
+ if ((pdata == NULL) || (pdata->touch == NULL))
+ return;
+
+ memcpy(&touch_pdata, pdata->touch,
+ sizeof(struct max8925_touch_pdata));
+ touch_devs[0].platform_data = &touch_pdata;
+ touch_devs[0].pdata_size = sizeof(touch_pdata);
+ touch_devs[0].num_resources = ARRAY_SIZE(touch_resources);
+ touch_devs[0].resources = &touch_resources[0];
+ ret = mfd_add_devices(chip->dev, 0, &touch_devs[0],
+ ARRAY_SIZE(touch_devs),
+ &touch_resources[0], chip->irq_base);
+ if (ret < 0)
+ dev_err(chip->dev, "Failed to add touch subdev\n");
+}
+
+static void __devinit device_power_init(struct max8925_chip *chip,
+ struct i2c_client *i2c,
+ struct max8925_platform_data *pdata)
+{
+ int ret;
+
+ if ((pdata == NULL) || (pdata->power == NULL))
+ return;
+
+ memcpy(&power_pdata, pdata->power,
+ sizeof(struct max8925_power_pdata));
+ power_devs[0].platform_data = &power_pdata;
+ power_devs[0].pdata_size = sizeof(power_pdata);
+ power_devs[0].num_resources = ARRAY_SIZE(power_resources);
+ power_devs[0].resources = &power_resources[0];
+ ret = mfd_add_devices(chip->dev, 0, &power_devs[0],
+ ARRAY_SIZE(power_devs),
+ &power_resources[0], chip->irq_base);
+ if (ret < 0)
+ dev_err(chip->dev, "Failed to add power supply subdev\n");
+}
+
+static void __devinit device_onkey_init(struct max8925_chip *chip,
+ struct i2c_client *i2c,
+ struct max8925_platform_data *pdata)
+{
+ int ret;
+
+ onkey_devs[0].num_resources = ARRAY_SIZE(onkey_resources);
+ onkey_devs[0].resources = &onkey_resources[0];
+ ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0],
+ ARRAY_SIZE(onkey_devs),
+ &onkey_resources[0], chip->irq_base);
+ if (ret < 0)
+ dev_err(chip->dev, "Failed to add onkey subdev\n");
+}
+
int __devinit max8925_device_init(struct max8925_chip *chip,
struct max8925_platform_data *pdata)
{
@@ -604,28 +685,18 @@ int __devinit max8925_device_init(struct max8925_chip *chip,
do {
ret = max8925_reg_read(chip->adc, MAX8925_TSC_IRQ);
} while (ret & MAX8925_NREF_OK);
- /* enaable ADC scheduler, interval is 1 second */
+ /* enable ADC scheduler, interval is 1 second */
max8925_set_bits(chip->adc, MAX8925_ADC_SCHED, 3, 2);
}
/* enable Momentary Power Loss */
max8925_set_bits(chip->rtc, MAX8925_MPL_CNTL, 1 << 4, 1 << 4);
- ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0],
- ARRAY_SIZE(rtc_devs),
- &rtc_resources[0], 0);
- if (ret < 0) {
- dev_err(chip->dev, "Failed to add rtc subdev\n");
- goto out;
- }
-
- ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0],
- ARRAY_SIZE(onkey_devs),
- &onkey_resources[0], 0);
- if (ret < 0) {
- dev_err(chip->dev, "Failed to add onkey subdev\n");
- goto out_dev;
- }
+ device_bk_init(chip, chip->i2c, pdata);
+ device_rtc_init(chip, chip->rtc, pdata);
+ device_touch_init(chip, chip->adc, pdata);
+ device_power_init(chip, chip->adc, pdata);
+ device_onkey_init(chip, chip->i2c, pdata);
if (pdata && pdata->regulator[0]) {
ret = mfd_add_devices(chip->dev, 0, ®ulator_devs[0],
@@ -637,42 +708,8 @@ int __devinit max8925_device_init(struct max8925_chip *chip,
}
}
- if (pdata && pdata->backlight) {
- ret = mfd_add_devices(chip->dev, 0, &backlight_devs[0],
- ARRAY_SIZE(backlight_devs),
- &backlight_resources[0], 0);
- if (ret < 0) {
- dev_err(chip->dev, "Failed to add backlight subdev\n");
- goto out_dev;
- }
- }
-
- if (pdata && pdata->power) {
- ret = mfd_add_devices(chip->dev, 0, &power_devs[0],
- ARRAY_SIZE(power_devs),
- &power_supply_resources[0], 0);
- if (ret < 0) {
- dev_err(chip->dev, "Failed to add power supply "
- "subdev\n");
- goto out_dev;
- }
- }
-
- if (pdata && pdata->touch) {
- ret = mfd_add_devices(chip->dev, 0, &touch_devs[0],
- ARRAY_SIZE(touch_devs),
- &touch_resources[0], 0);
- if (ret < 0) {
- dev_err(chip->dev, "Failed to add touch subdev\n");
- goto out_dev;
- }
- }
-
- return 0;
out_dev:
- mfd_remove_devices(chip->dev);
-out:
- return ret;
+ return 0;
}
void __devexit max8925_device_exit(struct max8925_chip *chip)
--
1.5.6.5
^ permalink raw reply related [flat|nested] 52+ messages in thread
* [PATCH 13/14] regulator: max8925: fix not add device if missing init data
2011-04-18 14:04 ` [PATCH 13/14] regulator: check name in initialization of max8925 Haojian Zhuang
2011-04-18 14:28 ` Mark Brown
@ 2011-04-20 11:55 ` Haojian Zhuang
2011-04-21 10:42 ` Mark Brown
1 sibling, 1 reply; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-20 11:55 UTC (permalink / raw)
To: sameo, haojian.zhuang, linux-kernel, lrg, broonie; +Cc: Haojian Zhuang
If regulator[0] is missed in init data, all regulators of max8925 won't
be initialized.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Cc: Liam Girdwood <lrg@slimlogic.co.uk>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/mfd/max8925-core.c | 171 ++++++++++++++++++---------------
drivers/regulator/max8925-regulator.c | 37 ++++----
include/linux/mfd/max8925.h | 3 +-
3 files changed, 112 insertions(+), 99 deletions(-)
diff --git a/drivers/mfd/max8925-core.c b/drivers/mfd/max8925-core.c
index a974711..93f2731 100644
--- a/drivers/mfd/max8925-core.c
+++ b/drivers/mfd/max8925-core.c
@@ -75,6 +75,32 @@ static struct resource onkey_resources[] __devinitdata = {
IORESOURCE_IRQ,},
};
+static struct resource regulator_resources[] __devinitdata = {
+ {MAX8925_ID_SD1, MAX8925_ID_SD1, "SD1", IORESOURCE_IO,},
+ {MAX8925_ID_SD2, MAX8925_ID_SD2, "SD2", IORESOURCE_IO,},
+ {MAX8925_ID_SD3, MAX8925_ID_SD3, "SD3", IORESOURCE_IO,},
+ {MAX8925_ID_LDO1, MAX8925_ID_LDO1, "LDO01", IORESOURCE_IO,},
+ {MAX8925_ID_LDO2, MAX8925_ID_LDO2, "LDO02", IORESOURCE_IO,},
+ {MAX8925_ID_LDO3, MAX8925_ID_LDO3, "LDO03", IORESOURCE_IO,},
+ {MAX8925_ID_LDO4, MAX8925_ID_LDO4, "LDO04", IORESOURCE_IO,},
+ {MAX8925_ID_LDO5, MAX8925_ID_LDO5, "LDO05", IORESOURCE_IO,},
+ {MAX8925_ID_LDO6, MAX8925_ID_LDO6, "LDO06", IORESOURCE_IO,},
+ {MAX8925_ID_LDO7, MAX8925_ID_LDO7, "LDO07", IORESOURCE_IO,},
+ {MAX8925_ID_LDO8, MAX8925_ID_LDO8, "LDO08", IORESOURCE_IO,},
+ {MAX8925_ID_LDO9, MAX8925_ID_LDO9, "LDO09", IORESOURCE_IO,},
+ {MAX8925_ID_LDO10, MAX8925_ID_LDO10, "LDO10", IORESOURCE_IO,},
+ {MAX8925_ID_LDO11, MAX8925_ID_LDO11, "LDO11", IORESOURCE_IO,},
+ {MAX8925_ID_LDO12, MAX8925_ID_LDO12, "LDO12", IORESOURCE_IO,},
+ {MAX8925_ID_LDO13, MAX8925_ID_LDO13, "LDO13", IORESOURCE_IO,},
+ {MAX8925_ID_LDO14, MAX8925_ID_LDO14, "LDO14", IORESOURCE_IO,},
+ {MAX8925_ID_LDO15, MAX8925_ID_LDO15, "LDO15", IORESOURCE_IO,},
+ {MAX8925_ID_LDO16, MAX8925_ID_LDO16, "LDO16", IORESOURCE_IO,},
+ {MAX8925_ID_LDO17, MAX8925_ID_LDO17, "LDO17", IORESOURCE_IO,},
+ {MAX8925_ID_LDO18, MAX8925_ID_LDO18, "LDO18", IORESOURCE_IO,},
+ {MAX8925_ID_LDO19, MAX8925_ID_LDO19, "LDO19", IORESOURCE_IO,},
+ {MAX8925_ID_LDO20, MAX8925_ID_LDO20, "LDO20", IORESOURCE_IO,},
+};
+
static struct mfd_cell bk_devs[] = {
{"max8925-backlight", -1,},
};
@@ -95,76 +121,36 @@ static struct mfd_cell onkey_devs[] = {
{"max8925-onkey", -1,},
};
+static struct mfd_cell regulator_devs[] = {
+ {"max8925-regulator", 0,},
+ {"max8925-regulator", 1,},
+ {"max8925-regulator", 2,},
+ {"max8925-regulator", 3,},
+ {"max8925-regulator", 4,},
+ {"max8925-regulator", 5,},
+ {"max8925-regulator", 6,},
+ {"max8925-regulator", 7,},
+ {"max8925-regulator", 8,},
+ {"max8925-regulator", 9,},
+ {"max8925-regulator", 10,},
+ {"max8925-regulator", 11,},
+ {"max8925-regulator", 12,},
+ {"max8925-regulator", 13,},
+ {"max8925-regulator", 14,},
+ {"max8925-regulator", 15,},
+ {"max8925-regulator", 16,},
+ {"max8925-regulator", 17,},
+ {"max8925-regulator", 18,},
+ {"max8925-regulator", 19,},
+ {"max8925-regulator", 20,},
+ {"max8925-regulator", 21,},
+ {"max8925-regulator", 22,},
+};
+
static struct max8925_backlight_pdata bk_pdata;
static struct max8925_touch_pdata touch_pdata;
static struct max8925_power_pdata power_pdata;
-
-#define MAX8925_REG_RESOURCE(_start, _end) \
-{ \
- .start = MAX8925_##_start, \
- .end = MAX8925_##_end, \
- .flags = IORESOURCE_IO, \
-}
-
-static struct resource regulator_resources[] = {
- MAX8925_REG_RESOURCE(SDCTL1, SDCTL1),
- MAX8925_REG_RESOURCE(SDCTL2, SDCTL2),
- MAX8925_REG_RESOURCE(SDCTL3, SDCTL3),
- MAX8925_REG_RESOURCE(LDOCTL1, LDOCTL1),
- MAX8925_REG_RESOURCE(LDOCTL2, LDOCTL2),
- MAX8925_REG_RESOURCE(LDOCTL3, LDOCTL3),
- MAX8925_REG_RESOURCE(LDOCTL4, LDOCTL4),
- MAX8925_REG_RESOURCE(LDOCTL5, LDOCTL5),
- MAX8925_REG_RESOURCE(LDOCTL6, LDOCTL6),
- MAX8925_REG_RESOURCE(LDOCTL7, LDOCTL7),
- MAX8925_REG_RESOURCE(LDOCTL8, LDOCTL8),
- MAX8925_REG_RESOURCE(LDOCTL9, LDOCTL9),
- MAX8925_REG_RESOURCE(LDOCTL10, LDOCTL10),
- MAX8925_REG_RESOURCE(LDOCTL11, LDOCTL11),
- MAX8925_REG_RESOURCE(LDOCTL12, LDOCTL12),
- MAX8925_REG_RESOURCE(LDOCTL13, LDOCTL13),
- MAX8925_REG_RESOURCE(LDOCTL14, LDOCTL14),
- MAX8925_REG_RESOURCE(LDOCTL15, LDOCTL15),
- MAX8925_REG_RESOURCE(LDOCTL16, LDOCTL16),
- MAX8925_REG_RESOURCE(LDOCTL17, LDOCTL17),
- MAX8925_REG_RESOURCE(LDOCTL18, LDOCTL18),
- MAX8925_REG_RESOURCE(LDOCTL19, LDOCTL19),
- MAX8925_REG_RESOURCE(LDOCTL20, LDOCTL20),
-};
-
-#define MAX8925_REG_DEVS(_id) \
-{ \
- .name = "max8925-regulator", \
- .num_resources = 1, \
- .resources = ®ulator_resources[MAX8925_ID_##_id], \
- .id = MAX8925_ID_##_id, \
-}
-
-static struct mfd_cell regulator_devs[] = {
- MAX8925_REG_DEVS(SD1),
- MAX8925_REG_DEVS(SD2),
- MAX8925_REG_DEVS(SD3),
- MAX8925_REG_DEVS(LDO1),
- MAX8925_REG_DEVS(LDO2),
- MAX8925_REG_DEVS(LDO3),
- MAX8925_REG_DEVS(LDO4),
- MAX8925_REG_DEVS(LDO5),
- MAX8925_REG_DEVS(LDO6),
- MAX8925_REG_DEVS(LDO7),
- MAX8925_REG_DEVS(LDO8),
- MAX8925_REG_DEVS(LDO9),
- MAX8925_REG_DEVS(LDO10),
- MAX8925_REG_DEVS(LDO11),
- MAX8925_REG_DEVS(LDO12),
- MAX8925_REG_DEVS(LDO13),
- MAX8925_REG_DEVS(LDO14),
- MAX8925_REG_DEVS(LDO15),
- MAX8925_REG_DEVS(LDO16),
- MAX8925_REG_DEVS(LDO17),
- MAX8925_REG_DEVS(LDO18),
- MAX8925_REG_DEVS(LDO19),
- MAX8925_REG_DEVS(LDO20),
-};
+static struct regulator_init_data regulator_pdata[ARRAY_SIZE(regulator_devs)];
enum {
FLAGS_ADC = 1, /* register in ADC component */
@@ -669,6 +655,45 @@ static void __devinit device_onkey_init(struct max8925_chip *chip,
dev_err(chip->dev, "Failed to add onkey subdev\n");
}
+static void __devinit device_regulator_init(struct max8925_chip *chip,
+ struct i2c_client *i2c,
+ struct max8925_platform_data *pdata)
+{
+ struct regulator_init_data *initdata;
+ int ret, i, seq;
+
+ if ((pdata == NULL) || (pdata->regulator == NULL))
+ return;
+
+ if (pdata->num_regulators > ARRAY_SIZE(regulator_devs))
+ pdata->num_regulators = ARRAY_SIZE(regulator_devs);
+
+ for (i = 0, seq = -1; i < pdata->num_regulators; i++) {
+ initdata = &pdata->regulator[i];
+ seq = *(unsigned int *)initdata->driver_data;
+ if ((seq < 0) || (seq > MAX8925_ID_MAX)) {
+ dev_err(chip->dev, "Wrong ID(%d) on regulator(%s)\n",
+ seq, initdata->constraints.name);
+ goto out;
+ }
+ memcpy(®ulator_pdata[i], &pdata->regulator[i],
+ sizeof(struct regulator_init_data));
+ regulator_devs[i].platform_data = ®ulator_pdata[i];
+ regulator_devs[i].pdata_size = sizeof(regulator_pdata[i]);
+ regulator_devs[i].num_resources = 1;
+ regulator_devs[i].resources = ®ulator_resources[seq];
+
+ ret = mfd_add_devices(chip->dev, 0, ®ulator_devs[i], 1,
+ ®ulator_resources[seq], 0);
+ if (ret < 0) {
+ dev_err(chip->dev, "Failed to add regulator subdev\n");
+ goto out;
+ }
+ }
+out:
+ return;
+}
+
int __devinit max8925_device_init(struct max8925_chip *chip,
struct max8925_platform_data *pdata)
{
@@ -697,18 +722,8 @@ int __devinit max8925_device_init(struct max8925_chip *chip,
device_touch_init(chip, chip->adc, pdata);
device_power_init(chip, chip->adc, pdata);
device_onkey_init(chip, chip->i2c, pdata);
+ device_regulator_init(chip, chip->i2c, pdata);
- if (pdata && pdata->regulator[0]) {
- ret = mfd_add_devices(chip->dev, 0, ®ulator_devs[0],
- ARRAY_SIZE(regulator_devs),
- ®ulator_resources[0], 0);
- if (ret < 0) {
- dev_err(chip->dev, "Failed to add regulator subdev\n");
- goto out_dev;
- }
- }
-
-out_dev:
return 0;
}
diff --git a/drivers/regulator/max8925-regulator.c b/drivers/regulator/max8925-regulator.c
index e4dbd66..733dcd2 100644
--- a/drivers/regulator/max8925-regulator.c
+++ b/drivers/regulator/max8925-regulator.c
@@ -236,39 +236,36 @@ static struct max8925_regulator_info max8925_regulator_info[] = {
MAX8925_LDO(20, 750, 3900, 50),
};
-static struct max8925_regulator_info * __devinit find_regulator_info(int id)
-{
- struct max8925_regulator_info *ri;
- int i;
-
- for (i = 0; i < ARRAY_SIZE(max8925_regulator_info); i++) {
- ri = &max8925_regulator_info[i];
- if (ri->desc.id == id)
- return ri;
- }
- return NULL;
-}
-
static int __devinit max8925_regulator_probe(struct platform_device *pdev)
{
struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
- struct max8925_platform_data *pdata = chip->dev->platform_data;
- struct max8925_regulator_info *ri;
+ struct max8925_regulator_info *ri = NULL;
+ struct regulator_init_data *pdata = pdev->dev.platform_data;
struct regulator_dev *rdev;
+ struct resource *res;
+ int i;
- ri = find_regulator_info(pdev->id);
- if (ri == NULL) {
- dev_err(&pdev->dev, "invalid regulator ID specified\n");
+ res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+ if (res == NULL) {
+ dev_err(&pdev->dev, "No I/O resource!\n");
+ return -EINVAL;
+ }
+ i = res->start;
+ if ((i < 0) || (i > MAX8925_ID_MAX)) {
+ dev_err(&pdev->dev, "Failed to find regulator %d\n",
+ res->start);
return -EINVAL;
}
+ ri = &max8925_regulator_info[i];
ri->i2c = chip->i2c;
ri->chip = chip;
+ /* replace driver_data with ri */
rdev = regulator_register(&ri->desc, &pdev->dev,
- pdata->regulator[pdev->id], ri);
+ pdata, ri);
if (IS_ERR(rdev)) {
dev_err(&pdev->dev, "failed to register regulator %s\n",
- ri->desc.name);
+ ri->desc.name);
return PTR_ERR(rdev);
}
diff --git a/include/linux/mfd/max8925.h b/include/linux/mfd/max8925.h
index 5259dfe..438a734 100644
--- a/include/linux/mfd/max8925.h
+++ b/include/linux/mfd/max8925.h
@@ -233,10 +233,11 @@ struct max8925_platform_data {
struct max8925_backlight_pdata *backlight;
struct max8925_touch_pdata *touch;
struct max8925_power_pdata *power;
- struct regulator_init_data *regulator[MAX8925_MAX_REGULATOR];
+ struct regulator_init_data *regulator;
int irq_base;
int tsc_irq;
+ int num_regulators;
};
extern int max8925_reg_read(struct i2c_client *, int);
--
1.5.6.5
^ permalink raw reply related [flat|nested] 52+ messages in thread
* [PATCH 14/14] regulator: 88pm8607: avoid to use constraint name in driver
2011-04-18 14:04 ` [PATCH 14/14] regulator: 88pm8607: avoid to use constraint name in driver Haojian Zhuang
2011-04-18 14:30 ` Mark Brown
@ 2011-04-20 11:56 ` Haojian Zhuang
1 sibling, 0 replies; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-20 11:56 UTC (permalink / raw)
To: sameo, haojian.zhuang, linux-kernel, lrg, broonie; +Cc: Haojian Zhuang
Avoid to use constraint name in driver. So use driver_data instead to
store regulator id in platform driver.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Cc: Liam Girdwood <lrg@slimlogic.co.uk>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/mfd/88pm860x-core.c | 35 ++++++++---------------------------
drivers/regulator/88pm8607.c | 25 +++++++++++++------------
2 files changed, 21 insertions(+), 39 deletions(-)
diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c
index 4fbc69b..3147c41 100644
--- a/drivers/mfd/88pm860x-core.c
+++ b/drivers/mfd/88pm860x-core.c
@@ -544,7 +544,7 @@ static void __devinit device_regulator_init(struct pm860x_chip *chip,
{
struct regulator_init_data *initdata;
int ret;
- int i, j;
+ int i, seq;
if ((pdata == NULL) || (pdata->regulator == NULL))
return;
@@ -552,31 +552,12 @@ static void __devinit device_regulator_init(struct pm860x_chip *chip,
if (pdata->num_regulators > ARRAY_SIZE(regulator_devs))
pdata->num_regulators = ARRAY_SIZE(regulator_devs);
- for (i = 0, j = -1; i < pdata->num_regulators; i++) {
+ for (i = 0, seq = -1; i < pdata->num_regulators; i++) {
initdata = &pdata->regulator[i];
- if (strstr(initdata->constraints.name, "BUCK")) {
- sscanf(initdata->constraints.name, "BUCK%d", &j);
- /* BUCK1 ~ BUCK3 */
- if ((j < 1) || (j > 3)) {
- dev_err(chip->dev, "Failed to add constraint "
- "(%s)\n", initdata->constraints.name);
- goto out;
- }
- j = (j - 1) + PM8607_ID_BUCK1;
- }
- if (strstr(initdata->constraints.name, "LDO")) {
- sscanf(initdata->constraints.name, "LDO%d", &j);
- /* LDO1 ~ LDO15 */
- if ((j < 1) || (j > 15)) {
- dev_err(chip->dev, "Failed to add constraint "
- "(%s)\n", initdata->constraints.name);
- goto out;
- }
- j = (j - 1) + PM8607_ID_LDO1;
- }
- if (j == -1) {
- dev_err(chip->dev, "Failed to add constraint (%s)\n",
- initdata->constraints.name);
+ seq = *(unsigned int *)initdata->driver_data;
+ if ((seq < 0) || (seq > PM8607_ID_RG_MAX)) {
+ dev_err(chip->dev, "Wrong ID(%d) on regulator(%s)\n",
+ seq, initdata->constraints.name);
goto out;
}
memcpy(®ulator_pdata[i], &pdata->regulator[i],
@@ -584,10 +565,10 @@ static void __devinit device_regulator_init(struct pm860x_chip *chip,
regulator_devs[i].platform_data = ®ulator_pdata[i];
regulator_devs[i].pdata_size = sizeof(regulator_pdata[i]);
regulator_devs[i].num_resources = 1;
- regulator_devs[i].resources = ®ulator_resources[j];
+ regulator_devs[i].resources = ®ulator_resources[seq];
ret = mfd_add_devices(chip->dev, 0, ®ulator_devs[i], 1,
- ®ulator_resources[j], 0);
+ ®ulator_resources[seq], 0);
if (ret < 0) {
dev_err(chip->dev, "Failed to add regulator subdev\n");
goto out;
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index 784ea77..1904be9 100644
--- a/drivers/regulator/88pm8607.c
+++ b/drivers/regulator/88pm8607.c
@@ -398,32 +398,33 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
{
struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
struct pm8607_regulator_info *info = NULL;
- struct regulator_init_data *pdata;
+ struct regulator_init_data *pdata = pdev->dev.platform_data;
+ struct resource *res;
int i;
- pdata = pdev->dev.platform_data;
- if (pdata == NULL)
+ res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+ if (res == NULL) {
+ dev_err(&pdev->dev, "No I/O resource!\n");
return -EINVAL;
-
+ }
for (i = 0; i < ARRAY_SIZE(pm8607_regulator_info); i++) {
info = &pm8607_regulator_info[i];
- if (!strcmp(info->desc.name, pdata->constraints.name))
+ if (info->desc.id == res->start)
break;
}
- if (i > ARRAY_SIZE(pm8607_regulator_info)) {
- dev_err(&pdev->dev, "Failed to find regulator %s\n",
- pdata->constraints.name);
+ if ((i < 0) || (i > PM8607_ID_RG_MAX)) {
+ dev_err(&pdev->dev, "Failed to find regulator %d\n",
+ res->start);
return -EINVAL;
}
-
info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion;
info->chip = chip;
/* check DVC ramp slope double */
- if (!strcmp(info->desc.name, "BUCK3"))
- if (info->chip->buck3_double)
- info->slope_double = 1;
+ if ((i == PM8607_ID_BUCK3) && info->chip->buck3_double)
+ info->slope_double = 1;
+ /* replace driver_data with info */
info->regulator = regulator_register(&info->desc, &pdev->dev,
pdata, info);
if (IS_ERR(info->regulator)) {
--
1.5.6.5
^ permalink raw reply related [flat|nested] 52+ messages in thread
* Re: [PATCH 13/14] regulator: max8925: fix not add device if missing init data
2011-04-20 11:55 ` [PATCH 13/14] regulator: max8925: fix not add device if missing init data Haojian Zhuang
@ 2011-04-21 10:42 ` Mark Brown
2011-04-21 11:13 ` Haojian Zhuang
0 siblings, 1 reply; 52+ messages in thread
From: Mark Brown @ 2011-04-21 10:42 UTC (permalink / raw)
To: Haojian Zhuang; +Cc: sameo, haojian.zhuang, linux-kernel, lrg
On Wed, Apr 20, 2011 at 07:55:39PM +0800, Haojian Zhuang wrote:
> If regulator[0] is missed in init data, all regulators of max8925 won't
> be initialized.
With a changelog like this I'd expect a small change to an error check
in the startup code or something but this is a very big change to the
driver initialisation.
> +static struct regulator_init_data regulator_pdata[ARRAY_SIZE(regulator_devs)];
That looks really suspicious, what happens if there's two of these
devices in the system?
> + memcpy(®ulator_pdata[i], &pdata->regulator[i],
> + sizeof(struct regulator_init_data));
> + regulator_devs[i].platform_data = ®ulator_pdata[i];
> + regulator_devs[i].pdata_size = sizeof(regulator_pdata[i]);
> + regulator_devs[i].num_resources = 1;
> + regulator_devs[i].resources = ®ulator_resources[seq];
> +
> + ret = mfd_add_devices(chip->dev, 0, ®ulator_devs[i], 1,
> + ®ulator_resources[seq], 0);
> + if (ret < 0) {
> + dev_err(chip->dev, "Failed to add regulator subdev\n");
> + goto out;
It's really unclear why the array is needed at all if you're registering
the devices one at a time.
> - if (pdata && pdata->regulator[0]) {
> - ret = mfd_add_devices(chip->dev, 0, ®ulator_devs[0],
> - ARRAY_SIZE(regulator_devs),
> - ®ulator_resources[0], 0);
> - if (ret < 0) {
> - dev_err(chip->dev, "Failed to add regulator subdev\n");
> - goto out_dev;
> - }
Surely the only change that's needed here is to remove the check to see
if pdata->regulator[0] is non-null?
^ permalink raw reply [flat|nested] 52+ messages in thread
* RE: [PATCH 13/14] regulator: max8925: fix not add device if missing init data
2011-04-21 10:42 ` Mark Brown
@ 2011-04-21 11:13 ` Haojian Zhuang
2011-04-21 12:03 ` Mark Brown
0 siblings, 1 reply; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-21 11:13 UTC (permalink / raw)
To: Mark Brown
Cc: sameo@linux.intel.com, haojian.zhuang@gmail.com,
linux-kernel@vger.kernel.org, lrg@slimlogic.co.uk
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb2312", Size: 2372 bytes --]
>-----Original Message-----
>From: Mark Brown [mailto:broonie@opensource.wolfsonmicro.com]
>Sent: 2011Äê4ÔÂ21ÈÕ 6:42 PM
>To: Haojian Zhuang
>Cc: sameo@linux.intel.com; haojian.zhuang@gmail.com; linux-
>kernel@vger.kernel.org; lrg@slimlogic.co.uk
>Subject: Re: [PATCH 13/14] regulator: max8925: fix not add device if
>missing init data
>
>On Wed, Apr 20, 2011 at 07:55:39PM +0800, Haojian Zhuang wrote:
>> If regulator[0] is missed in init data, all regulators of max8925
>won't
>> be initialized.
>
>With a changelog like this I'd expect a small change to an error check
>in the startup code or something but this is a very big change to the
>driver initialisation.
>
>> +static struct regulator_init_data
>regulator_pdata[ARRAY_SIZE(regulator_devs)];
>
>That looks really suspicious, what happens if there's two of these
>devices in the system?
>
It's impossible to use two PMIC in one system. At least, I didn't hear.
>> + memcpy(®ulator_pdata[i], &pdata->regulator[i],
>> + sizeof(struct regulator_init_data));
>> + regulator_devs[i].platform_data = ®ulator_pdata[i];
>> + regulator_devs[i].pdata_size = sizeof(regulator_pdata[i]);
>> + regulator_devs[i].num_resources = 1;
>> + regulator_devs[i].resources = ®ulator_resources[seq];
>> +
>> + ret = mfd_add_devices(chip->dev, 0, ®ulator_devs[i], 1,
>> + ®ulator_resources[seq], 0);
>> + if (ret < 0) {
>> + dev_err(chip->dev, "Failed to add regulator subdev\n");
>> + goto out;
>
>It's really unclear why the array is needed at all if you're registering
>the devices one at a time.
>
Although there're a lot of regulators, maybe only parts of them are used.
So only add the necessary one. Others will be passed. The number is got
from platform data.
>> - if (pdata && pdata->regulator[0]) {
>> - ret = mfd_add_devices(chip->dev, 0, ®ulator_devs[0],
>> - ARRAY_SIZE(regulator_devs),
>> - ®ulator_resources[0], 0);
>> - if (ret < 0) {
>> - dev_err(chip->dev, "Failed to add regulator subdev\n");
>> - goto out_dev;
>> - }
>
>Surely the only change that's needed here is to remove the check to see
>if pdata->regulator[0] is non-null?
All above changes are necessary to me.
Thanks
Haojian
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 13/14] regulator: max8925: fix not add device if missing init data
2011-04-21 11:13 ` Haojian Zhuang
@ 2011-04-21 12:03 ` Mark Brown
2011-04-21 15:23 ` Haojian Zhuang
0 siblings, 1 reply; 52+ messages in thread
From: Mark Brown @ 2011-04-21 12:03 UTC (permalink / raw)
To: Haojian Zhuang
Cc: sameo@linux.intel.com, haojian.zhuang@gmail.com,
linux-kernel@vger.kernel.org, lrg@slimlogic.co.uk
On Thu, Apr 21, 2011 at 04:13:28AM -0700, Haojian Zhuang wrote:
> >> +static struct regulator_init_data
> >regulator_pdata[ARRAY_SIZE(regulator_devs)];
> >That looks really suspicious, what happens if there's two of these
> >devices in the system?
> It's impossible to use two PMIC in one system. At least, I didn't hear.
I don't believe that. It's not going to be a common case but it will be
possible.
> >It's really unclear why the array is needed at all if you're registering
> >the devices one at a time.
> Although there're a lot of regulators, maybe only parts of them are used.
> So only add the necessary one. Others will be passed. The number is got
> from platform data.
You're missing the point here. You're registering a device at a time
but for some reason the platform data is being stored in an array in
order to pass it in, even though only a single element in the array is
in use.
> >> - if (pdata && pdata->regulator[0]) {
> >> - ret = mfd_add_devices(chip->dev, 0, ®ulator_devs[0],
> >> - ARRAY_SIZE(regulator_devs),
> >> - ®ulator_resources[0], 0);
> >> - if (ret < 0) {
> >> - dev_err(chip->dev, "Failed to add regulator subdev\n");
> >> - goto out_dev;
> >> - }
> >Surely the only change that's needed here is to remove the check to see
> >if pdata->regulator[0] is non-null?
> All above changes are necessary to me.
What makes you say this? If you remove the check for the first entry
being null then the driver will go and register all the regulators which
seems fine. That seems like it fixes the problem with skipping all the
regulators if the first one has no platform data.
You're really not explaining the changes you're trying to make here
terribly well, the changes you're making seem very substantial relative
to what you say you're trying to do.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 13/14] regulator: max8925: fix not add device if missing init data
2011-04-21 12:03 ` Mark Brown
@ 2011-04-21 15:23 ` Haojian Zhuang
2011-04-21 18:32 ` Mark Brown
0 siblings, 1 reply; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-21 15:23 UTC (permalink / raw)
To: Mark Brown
Cc: Haojian Zhuang, sameo@linux.intel.com,
linux-kernel@vger.kernel.org, lrg@slimlogic.co.uk
On Thu, Apr 21, 2011 at 8:03 PM, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:
> On Thu, Apr 21, 2011 at 04:13:28AM -0700, Haojian Zhuang wrote:
>
>> >> +static struct regulator_init_data
>> >regulator_pdata[ARRAY_SIZE(regulator_devs)];
>
>> >That looks really suspicious, what happens if there's two of these
>> >devices in the system?
>
>> It's impossible to use two PMIC in one system. At least, I didn't hear.
>
> I don't believe that. It's not going to be a common case but it will be
> possible.
>
OK, I can allocate memory to handle this.
>> >It's really unclear why the array is needed at all if you're registering
>> >the devices one at a time.
>
>> Although there're a lot of regulators, maybe only parts of them are used.
>> So only add the necessary one. Others will be passed. The number is got
>> from platform data.
>
> You're missing the point here. You're registering a device at a time
> but for some reason the platform data is being stored in an array in
> order to pass it in, even though only a single element in the array is
> in use.
>
I can allocate memory for platform data.
>> >> - if (pdata && pdata->regulator[0]) {
>> >> - ret = mfd_add_devices(chip->dev, 0, ®ulator_devs[0],
>> >> - ARRAY_SIZE(regulator_devs),
>> >> - ®ulator_resources[0], 0);
>> >> - if (ret < 0) {
>> >> - dev_err(chip->dev, "Failed to add regulator subdev\n");
>> >> - goto out_dev;
>> >> - }
>
>> >Surely the only change that's needed here is to remove the check to see
>> >if pdata->regulator[0] is non-null?
>
>> All above changes are necessary to me.
>
> What makes you say this? If you remove the check for the first entry
> being null then the driver will go and register all the regulators which
> seems fine. That seems like it fixes the problem with skipping all the
> regulators if the first one has no platform data.
>
If I keep original method and only fix the null issue on regulator[0], I can
also register regulators. But it'll display error messages since
regulator_init_data is null while it's registers.
After switching to the current method, I only register the ones that I really
need. So I can avoid some error messages in boot time.
An array seems not good, and I can switch to allocate memory.
> You're really not explaining the changes you're trying to make here
> terribly well, the changes you're making seem very substantial relative
> to what you say you're trying to do.
>
Yes, I'll list all changes in log.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 13/14] regulator: max8925: fix not add device if missing init data
2011-04-21 15:23 ` Haojian Zhuang
@ 2011-04-21 18:32 ` Mark Brown
0 siblings, 0 replies; 52+ messages in thread
From: Mark Brown @ 2011-04-21 18:32 UTC (permalink / raw)
To: Haojian Zhuang
Cc: Haojian Zhuang, sameo@linux.intel.com,
linux-kernel@vger.kernel.org, lrg@slimlogic.co.uk
On Thu, Apr 21, 2011 at 11:23:19PM +0800, Haojian Zhuang wrote:
> On Thu, Apr 21, 2011 at 8:03 PM, Mark Brown
> > What makes you say this? If you remove the check for the first entry
> > being null then the driver will go and register all the regulators which
> > seems fine. That seems like it fixes the problem with skipping all the
> > regulators if the first one has no platform data.
> If I keep original method and only fix the null issue on regulator[0], I can
> also register regulators. But it'll display error messages since
> regulator_init_data is null while it's registers.
Registering regulators with null init data seems like a reasonable thing
to want to do - let's just remove the error message.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 02/14] input: touchscreen: move initialization in 88pm860x
2011-04-18 14:03 ` [PATCH 02/14] input: touchscreen: move initialization " Haojian Zhuang
@ 2011-04-26 8:57 ` Samuel Ortiz
0 siblings, 0 replies; 52+ messages in thread
From: Samuel Ortiz @ 2011-04-26 8:57 UTC (permalink / raw)
To: Haojian Zhuang
Cc: haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo, johnpol,
cbou, dwmw2, lrg, broonie
Hi Haojian,
On Mon, Apr 18, 2011 at 10:03:59PM +0800, Haojian Zhuang wrote:
> Move the GPADC initialization code from mfd driver to touch driver.
I think this should go through Dmitry's tree. If he's ok with that:
Acked-by: Samuel Ortiz <sameo@linux.intel.com>
Cheers,
Samuel.
--
Intel Open Source Technology Centre
http://oss.intel.com/
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 03/14] rtc: add 88pm860x rtc
2011-04-18 14:04 ` [PATCH 03/14] rtc: add 88pm860x rtc Haojian Zhuang
@ 2011-04-26 8:58 ` Samuel Ortiz
0 siblings, 0 replies; 52+ messages in thread
From: Samuel Ortiz @ 2011-04-26 8:58 UTC (permalink / raw)
To: Haojian Zhuang
Cc: haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo, johnpol,
cbou, dwmw2, lrg, broonie
Hi Haojian,
On Mon, Apr 18, 2011 at 10:04:00PM +0800, Haojian Zhuang wrote:
> Support RTC component in 88PM860x. Also support synchronize time from
> 88PM860x RTC to another RTC device. It should be implemented in
> sync callback API.
>
> While 88PM860x RTC is enabled, it can do RTC calibration to gurantee
> enough power is supplied on VRTC domain of 88PM860x.
For the MFD part:
Acked-by: Samuel Ortiz <sameo@linux.intel.com>
Cheers,
Samuel.
--
Intel Open Source Technology Centre
http://oss.intel.com/
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 08/14] mfd: use platform_data in max8925
2011-04-20 11:54 ` Haojian Zhuang
@ 2011-04-26 9:45 ` Samuel Ortiz
0 siblings, 0 replies; 52+ messages in thread
From: Samuel Ortiz @ 2011-04-26 9:45 UTC (permalink / raw)
To: Haojian Zhuang; +Cc: haojian.zhuang, linux-kernel, lrg, broonie
Hi Haojian,
On Wed, Apr 20, 2011 at 07:54:26PM +0800, Haojian Zhuang wrote:
> Use platform_data to pass parameters to client driver.
You need to provide more details about why this is needed, and how the sub
devices resources can change from one platform to another.
Also, some additional comments:
> +static struct resource bk_resources[] __devinitdata = {
> + {0, 0, "max8925-backlight", IORESOURCE_IO,},
> };
Do you really need to define this empty resource ? Can't you do that from the
device_*_init() routines ?
> +static void __devinit device_bk_init(struct max8925_chip *chip,
> + struct i2c_client *i2c,
> + struct max8925_platform_data *pdata)
I don't think you need to pass the i2c pointer here.
Cheers,
Samuel.
--
Intel Open Source Technology Centre
http://oss.intel.com/
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 06/14] mfd: pxa-w1: MFD driver for PXA 1wire control + DS1WM chip
2011-04-18 14:04 ` [PATCH 06/14] mfd: pxa-w1: MFD driver for PXA 1wire control + DS1WM chip Haojian Zhuang
@ 2011-04-26 9:48 ` Samuel Ortiz
2011-05-14 14:21 ` Haojian Zhuang
0 siblings, 1 reply; 52+ messages in thread
From: Samuel Ortiz @ 2011-04-26 9:48 UTC (permalink / raw)
To: Haojian Zhuang
Cc: haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo, johnpol,
cbou, dwmw2, lrg, broonie
Hi Haojian,
On Mon, Apr 18, 2011 at 10:04:03PM +0800, Haojian Zhuang wrote:
> This driver provides registers and IRQ of PXA3xx chips to the ds1wm driver.
I see why this is needed, but I really think the ds1wm driver should be
converted to a regular platform device. The MFD driver below is just adding a
useless middle layer between your platform code and the ds1wm one.
Cheers,
Samuel.
--
Intel Open Source Technology Centre
http://oss.intel.com/
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 07/14] mfd: fix build warning on 88pm860x
2011-04-18 14:04 ` [PATCH 07/14] mfd: fix build warning on 88pm860x Haojian Zhuang
@ 2011-04-26 9:49 ` Samuel Ortiz
2011-04-26 16:44 ` Haojian Zhuang
0 siblings, 1 reply; 52+ messages in thread
From: Samuel Ortiz @ 2011-04-26 9:49 UTC (permalink / raw)
To: Haojian Zhuang
Cc: haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo, johnpol,
cbou, dwmw2, lrg, broonie
Hi Haojian,
On Mon, Apr 18, 2011 at 10:04:04PM +0800, Haojian Zhuang wrote:
> WARNING: vmlinux.o(.devinit.text+0x6c4): Section mismatch in reference
> from the function device_onkey_init() to the (unknown reference)
> .init.data:(unknown)
> The function __devinit device_onkey_init() references a (unknown reference)
> __initdata (unknown).
> If (unknown) is only used by device_onkey_init then annotate (unknown)
> with a matching annotation.
>
> It's caused by using __initdata on mfd cell resources. Replace __initdata
> with __devinitdata.
Patch applied, many thanks.
Cheers,
Samuel.
--
Intel Open Source Technology Centre
http://oss.intel.com/
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 07/14] mfd: fix build warning on 88pm860x
2011-04-26 9:49 ` Samuel Ortiz
@ 2011-04-26 16:44 ` Haojian Zhuang
2011-04-26 16:47 ` Samuel Ortiz
0 siblings, 1 reply; 52+ messages in thread
From: Haojian Zhuang @ 2011-04-26 16:44 UTC (permalink / raw)
To: Samuel Ortiz
Cc: Haojian Zhuang, linux-kernel, dmitry.torokhov, a.zummo, johnpol,
cbou, dwmw2, lrg, broonie
On Tue, Apr 26, 2011 at 5:49 PM, Samuel Ortiz <sameo@linux.intel.com> wrote:
> Hi Haojian,
>
> On Mon, Apr 18, 2011 at 10:04:04PM +0800, Haojian Zhuang wrote:
>> WARNING: vmlinux.o(.devinit.text+0x6c4): Section mismatch in reference
>> from the function device_onkey_init() to the (unknown reference)
>> .init.data:(unknown)
>> The function __devinit device_onkey_init() references a (unknown reference)
>> __initdata (unknown).
>> If (unknown) is only used by device_onkey_init then annotate (unknown)
>> with a matching annotation.
>>
>> It's caused by using __initdata on mfd cell resources. Replace __initdata
>> with __devinitdata.
> Patch applied, many thanks.
>
Thanks a lot. But I can't find it in your mfd tree. Could you update
your tree? Since
I need to rebase it and format new patches.
Best Regards
Haojian
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 07/14] mfd: fix build warning on 88pm860x
2011-04-26 16:44 ` Haojian Zhuang
@ 2011-04-26 16:47 ` Samuel Ortiz
0 siblings, 0 replies; 52+ messages in thread
From: Samuel Ortiz @ 2011-04-26 16:47 UTC (permalink / raw)
To: Haojian Zhuang
Cc: Haojian Zhuang, linux-kernel, dmitry.torokhov, a.zummo, johnpol,
cbou, dwmw2, lrg, broonie
Hi Haojian,
On Wed, Apr 27, 2011 at 12:44:23AM +0800, Haojian Zhuang wrote:
> On Tue, Apr 26, 2011 at 5:49 PM, Samuel Ortiz <sameo@linux.intel.com> wrote:
> > Hi Haojian,
> >
> > On Mon, Apr 18, 2011 at 10:04:04PM +0800, Haojian Zhuang wrote:
> >> WARNING: vmlinux.o(.devinit.text+0x6c4): Section mismatch in reference
> >> from the function device_onkey_init() to the (unknown reference)
> >> .init.data:(unknown)
> >> The function __devinit device_onkey_init() references a (unknown reference)
> >> __initdata (unknown).
> >> If (unknown) is only used by device_onkey_init then annotate (unknown)
> >> with a matching annotation.
> >>
> >> It's caused by using __initdata on mfd cell resources. Replace __initdata
> >> with __devinitdata.
> > Patch applied, many thanks.
> >
> Thanks a lot. But I can't find it in your mfd tree. Could you update
> your tree? Since
> I need to rebase it and format new patches.
I just pushed to kernel.org. It's going to be there soon.
Cheers,
Samuel.
--
Intel Open Source Technology Centre
http://oss.intel.com/
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 11/14] power_supply: max8925: use platform_data from cell
2011-04-18 21:49 ` Anton Vorontsov
@ 2011-05-02 15:15 ` Samuel Ortiz
0 siblings, 0 replies; 52+ messages in thread
From: Samuel Ortiz @ 2011-05-02 15:15 UTC (permalink / raw)
To: Anton Vorontsov
Cc: Haojian Zhuang, haojian.zhuang, linux-kernel, dmitry.torokhov,
a.zummo, johnpol, dwmw2, lrg, broonie
Hi Haojian, Anton,
On Tue, Apr 19, 2011 at 01:49:19AM +0400, Anton Vorontsov wrote:
> On Mon, Apr 18, 2011 at 10:04:08PM +0800, Haojian Zhuang wrote:
> > Avoid to get platform_data from parent device. Get it from mfd cell
> > device instead.
> >
> > Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
> > Cc: Anton Vorontsov <cbou@mail.ru>
> > Cc: David Woodhouse <dwmw2@infradead.org>
> > ---
>
> Acked-by: Anton Vorontsov <cbouatmailru@gmail.com>
Thanks, patch applied to my for-next branch.
Cheers,
Samuel.
--
Intel Open Source Technology Centre
http://oss.intel.com/
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 12/14] regulator: max8925: enable i2c sequence for control
2011-04-18 14:04 ` [PATCH 12/14] regulator: max8925: enable i2c sequence for control Haojian Zhuang
2011-04-18 14:27 ` Mark Brown
@ 2011-05-02 15:16 ` Samuel Ortiz
1 sibling, 0 replies; 52+ messages in thread
From: Samuel Ortiz @ 2011-05-02 15:16 UTC (permalink / raw)
To: Haojian Zhuang
Cc: haojian.zhuang, linux-kernel, dmitry.torokhov, a.zummo, johnpol,
cbou, dwmw2, lrg, broonie
Hi Haojian,
On Mon, Apr 18, 2011 at 10:04:09PM +0800, Haojian Zhuang wrote:
> Force to enable i2c as power up/down sequence. Otherwise, SD/LDO can't
> be enabled or disabled via accessing i2c bus.
>
Patch applied to my for-next branch, thanks.
Cheers,
Samuel.
--
Intel Open Source Technology Centre
http://oss.intel.com/
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 06/14] mfd: pxa-w1: MFD driver for PXA 1wire control + DS1WM chip
2011-04-26 9:48 ` Samuel Ortiz
@ 2011-05-14 14:21 ` Haojian Zhuang
2011-05-14 19:40 ` Russell King - ARM Linux
2011-05-22 20:00 ` Samuel Ortiz
0 siblings, 2 replies; 52+ messages in thread
From: Haojian Zhuang @ 2011-05-14 14:21 UTC (permalink / raw)
To: Samuel Ortiz
Cc: Haojian Zhuang, linux-kernel, dmitry.torokhov, a.zummo, johnpol,
cbou, dwmw2, lrg, broonie, linux-arm-kernel
On Tue, Apr 26, 2011 at 5:48 PM, Samuel Ortiz <sameo@linux.intel.com> wrote:
> Hi Haojian,
>
> On Mon, Apr 18, 2011 at 10:04:03PM +0800, Haojian Zhuang wrote:
>> This driver provides registers and IRQ of PXA3xx chips to the ds1wm driver.
> I see why this is needed, but I really think the ds1wm driver should be
> converted to a regular platform device. The MFD driver below is just adding a
> useless middle layer between your platform code and the ds1wm one.
>
I'm OK to use the regulator platform device for ds1wm driver except
for one concern.
ds1wm driver is designed for mfd cell driver. I need to update it as
regulator platform
driver first. cell->enable() / cell->disable() is used to enable clock
for ds1wm driver.
So I need to change the API from cell->enable/disable to clk_enable()
/ clk_disable().
But the key issue is that there's no common structure for clkdev. Now
clkdev is only
designed for deeply machine depend.
>From my view is that we need a common structure for clkdev. Then mfd driver can
get benefit from this. Some client driver can be written as regulator
platform device.
And mfd driver can use them seamless. What's your opinion?
Best Regards
Haojian
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 06/14] mfd: pxa-w1: MFD driver for PXA 1wire control + DS1WM chip
2011-05-14 14:21 ` Haojian Zhuang
@ 2011-05-14 19:40 ` Russell King - ARM Linux
2011-05-14 22:23 ` Mark Brown
2011-05-22 20:00 ` Samuel Ortiz
1 sibling, 1 reply; 52+ messages in thread
From: Russell King - ARM Linux @ 2011-05-14 19:40 UTC (permalink / raw)
To: Haojian Zhuang
Cc: Samuel Ortiz, johnpol, a.zummo, broonie, dmitry.torokhov,
Haojian Zhuang, linux-kernel, cbou, dwmw2, linux-arm-kernel, lrg
On Sat, May 14, 2011 at 10:21:25PM +0800, Haojian Zhuang wrote:
> But the key issue is that there's no common structure for clkdev. Now
> clkdev is only designed for deeply machine depend.
>
> >From my view is that we need a common structure for clkdev.
You mean struct clk.
As I said on our call on Thursday, everyone knows this, and it's
something that has been worked on for the last year. Concensus had
been reached and everyone had settled on a proposal, and just when
we were almost ready to merge it, the concensus fell apart again.
As a result of that, a common struct clk has been delayed - it's not
going to be in place for 2.6.40 (three months) but maybe we can reach
concensus again for the .41 merge window.
As I also said, this issue was talked about in a session at the Linaro
conference, and it will be interesting to hear what the result of that
session was. At the moment, I'm entirely out of the loop on many things
that were discussed there (except for a message from tglx.)
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 06/14] mfd: pxa-w1: MFD driver for PXA 1wire control + DS1WM chip
2011-05-14 19:40 ` Russell King - ARM Linux
@ 2011-05-14 22:23 ` Mark Brown
0 siblings, 0 replies; 52+ messages in thread
From: Mark Brown @ 2011-05-14 22:23 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: Haojian Zhuang, Samuel Ortiz, johnpol, a.zummo, dmitry.torokhov,
Haojian Zhuang, linux-kernel, cbou, dwmw2, linux-arm-kernel, lrg
On Sat, May 14, 2011 at 08:40:17PM +0100, Russell King - ARM Linux wrote:
> As I also said, this issue was talked about in a session at the Linaro
> conference, and it will be interesting to hear what the result of that
> session was. At the moment, I'm entirely out of the loop on many things
> that were discussed there (except for a message from tglx.)
Everything should have had some live noted minutes linked off this site:
http://summit.ubuntu.com/uds-o/
probably everything interesting is on this page:
http://summit.ubuntu.com/uds-o/track/linaro-kernel/
(in etherpad, you want the icon that looks a bit like a notepad on the
left of the box in the talk). They won't always be accurate as they
were done live and not 100% reviewed but might be helpful.
Several people had actions to bring things to the list so I'd expect to
see some more digested mails hitting in the next week or two.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH 06/14] mfd: pxa-w1: MFD driver for PXA 1wire control + DS1WM chip
2011-05-14 14:21 ` Haojian Zhuang
2011-05-14 19:40 ` Russell King - ARM Linux
@ 2011-05-22 20:00 ` Samuel Ortiz
1 sibling, 0 replies; 52+ messages in thread
From: Samuel Ortiz @ 2011-05-22 20:00 UTC (permalink / raw)
To: Haojian Zhuang
Cc: Haojian Zhuang, linux-kernel, dmitry.torokhov, a.zummo, johnpol,
cbou, dwmw2, lrg, broonie, linux-arm-kernel
Hi Haojian,
On Sat, May 14, 2011 at 10:21:25PM +0800, Haojian Zhuang wrote:
> On Tue, Apr 26, 2011 at 5:48 PM, Samuel Ortiz <sameo@linux.intel.com> wrote:
> > Hi Haojian,
> >
> > On Mon, Apr 18, 2011 at 10:04:03PM +0800, Haojian Zhuang wrote:
> >> This driver provides registers and IRQ of PXA3xx chips to the ds1wm driver.
> > I see why this is needed, but I really think the ds1wm driver should be
> > converted to a regular platform device. The MFD driver below is just adding a
> > useless middle layer between your platform code and the ds1wm one.
> >
> I'm OK to use the regulator platform device for ds1wm driver except
> for one concern.
> ds1wm driver is designed for mfd cell driver. I need to update it as
> regulator platform
> driver first. cell->enable() / cell->disable() is used to enable clock
> for ds1wm driver.
> So I need to change the API from cell->enable/disable to clk_enable()
> / clk_disable().
>
> But the key issue is that there's no common structure for clkdev. Now
> clkdev is only
> designed for deeply machine depend.
>
> From my view is that we need a common structure for clkdev. Then mfd driver can
> get benefit from this. Some client driver can be written as regulator
> platform device.
> And mfd driver can use them seamless. What's your opinion?
I may be missing your point, but what is preventing you from calling the clock
API from drivers/w1/masters/ds1wm.c, the same way you're calling it from this
patch ?
Cheers,
Samuel.
--
Intel Open Source Technology Centre
http://oss.intel.com/
^ permalink raw reply [flat|nested] 52+ messages in thread
end of thread, other threads:[~2011-05-22 20:00 UTC | newest]
Thread overview: 52+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <2011041801>
2011-04-18 14:03 ` [PATCH v2 00/14] Update 88pm860x and max8925 MFD driver Haojian Zhuang
2011-04-18 14:03 ` [PATCH 01/14] input: touchscreen: use polling mode in 88pm860x Haojian Zhuang
2011-04-18 14:03 ` [PATCH 02/14] input: touchscreen: move initialization " Haojian Zhuang
2011-04-26 8:57 ` Samuel Ortiz
2011-04-18 14:04 ` [PATCH 03/14] rtc: add 88pm860x rtc Haojian Zhuang
2011-04-26 8:58 ` Samuel Ortiz
2011-04-18 14:04 ` [PATCH 04/14] input: set the long press detection in 88pm860x onkey Haojian Zhuang
2011-04-18 14:04 ` [PATCH 05/14] w1: add DS278x slave driver Haojian Zhuang
2011-04-18 14:04 ` [PATCH 06/14] mfd: pxa-w1: MFD driver for PXA 1wire control + DS1WM chip Haojian Zhuang
2011-04-26 9:48 ` Samuel Ortiz
2011-05-14 14:21 ` Haojian Zhuang
2011-05-14 19:40 ` Russell King - ARM Linux
2011-05-14 22:23 ` Mark Brown
2011-05-22 20:00 ` Samuel Ortiz
2011-04-18 14:04 ` [PATCH 07/14] mfd: fix build warning on 88pm860x Haojian Zhuang
2011-04-26 9:49 ` Samuel Ortiz
2011-04-26 16:44 ` Haojian Zhuang
2011-04-26 16:47 ` Samuel Ortiz
2011-04-18 14:04 ` [PATCH 08/14] mfd: use platform_data in max8925 Haojian Zhuang
2011-04-20 11:54 ` Haojian Zhuang
2011-04-26 9:45 ` Samuel Ortiz
2011-04-18 14:04 ` [PATCH 09/14] input: get irq from resource in max8925 onkey Haojian Zhuang
2011-04-18 14:04 ` [PATCH 10/14] rtc: avoid to use hardcoding irq number in max8925 Haojian Zhuang
2011-04-18 14:04 ` [PATCH 11/14] power_supply: max8925: use platform_data from cell Haojian Zhuang
2011-04-18 21:49 ` Anton Vorontsov
2011-05-02 15:15 ` Samuel Ortiz
2011-04-18 14:04 ` [PATCH 12/14] regulator: max8925: enable i2c sequence for control Haojian Zhuang
2011-04-18 14:27 ` Mark Brown
2011-05-02 15:16 ` Samuel Ortiz
2011-04-18 14:04 ` [PATCH 13/14] regulator: check name in initialization of max8925 Haojian Zhuang
2011-04-18 14:28 ` Mark Brown
2011-04-18 15:33 ` Haojian Zhuang
2011-04-18 16:04 ` Mark Brown
2011-04-19 2:42 ` Haojian Zhuang
2011-04-19 8:09 ` Mark Brown
2011-04-19 8:28 ` Haojian Zhuang
2011-04-19 10:51 ` Mark Brown
2011-04-19 11:33 ` Haojian Zhuang
2011-04-20 11:55 ` [PATCH 13/14] regulator: max8925: fix not add device if missing init data Haojian Zhuang
2011-04-21 10:42 ` Mark Brown
2011-04-21 11:13 ` Haojian Zhuang
2011-04-21 12:03 ` Mark Brown
2011-04-21 15:23 ` Haojian Zhuang
2011-04-21 18:32 ` Mark Brown
2011-04-18 14:04 ` [PATCH 14/14] regulator: 88pm8607: avoid to use constraint name in driver Haojian Zhuang
2011-04-18 14:30 ` Mark Brown
2011-04-18 15:38 ` Haojian Zhuang
2011-04-18 16:02 ` Mark Brown
2011-04-19 2:45 ` Haojian Zhuang
2011-04-19 8:13 ` Mark Brown
2011-04-19 11:34 ` Haojian Zhuang
2011-04-20 11:56 ` Haojian Zhuang
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).