Commit 95e50f6a authored by Aaro Koskinen's avatar Aaro Koskinen Committed by Samuel Ortiz

mfd: retu: Add Tahvo support

Tahvo is a multi-function device on Nokia 770, implementing USB
transceiver and charge/battery control.

It's so close to Retu that a single driver can support both.
Signed-off-by: default avatarAaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent 360e64d8
...@@ -371,13 +371,13 @@ config MFD_VIPERBOARD ...@@ -371,13 +371,13 @@ config MFD_VIPERBOARD
The drivers do not support all features the board exposes. The drivers do not support all features the board exposes.
config MFD_RETU config MFD_RETU
tristate "Nokia Retu multi-function device" tristate "Nokia Retu and Tahvo multi-function device"
select MFD_CORE select MFD_CORE
depends on I2C && GENERIC_HARDIRQS depends on I2C && GENERIC_HARDIRQS
select REGMAP_IRQ select REGMAP_IRQ
help help
Retu is a multi-function device found on Nokia Internet Tablets Retu and Tahvo are a multi-function devices found on Nokia
(770, N800 and N810). Internet Tablets (770, N800 and N810).
config MFD_PCF50633 config MFD_PCF50633
tristate "NXP PCF50633" tristate "NXP PCF50633"
......
/* /*
* Retu MFD driver * Retu/Tahvo MFD driver
* *
* Copyright (C) 2004, 2005 Nokia Corporation * Copyright (C) 2004, 2005 Nokia Corporation
* *
...@@ -33,7 +33,8 @@ ...@@ -33,7 +33,8 @@
#define RETU_REG_ASICR 0x00 /* ASIC ID and revision */ #define RETU_REG_ASICR 0x00 /* ASIC ID and revision */
#define RETU_REG_ASICR_VILMA (1 << 7) /* Bit indicating Vilma */ #define RETU_REG_ASICR_VILMA (1 << 7) /* Bit indicating Vilma */
#define RETU_REG_IDR 0x01 /* Interrupt ID */ #define RETU_REG_IDR 0x01 /* Interrupt ID */
#define RETU_REG_IMR 0x02 /* Interrupt mask */ #define RETU_REG_IMR 0x02 /* Interrupt mask (Retu) */
#define TAHVO_REG_IMR 0x03 /* Interrupt mask (Tahvo) */
/* Interrupt sources */ /* Interrupt sources */
#define RETU_INT_PWR 0 /* Power button */ #define RETU_INT_PWR 0 /* Power button */
...@@ -84,6 +85,62 @@ static struct regmap_irq_chip retu_irq_chip = { ...@@ -84,6 +85,62 @@ static struct regmap_irq_chip retu_irq_chip = {
/* Retu device registered for the power off. */ /* Retu device registered for the power off. */
static struct retu_dev *retu_pm_power_off; static struct retu_dev *retu_pm_power_off;
static struct resource tahvo_usb_res[] = {
{
.name = "tahvo-usb",
.start = TAHVO_INT_VBUS,
.end = TAHVO_INT_VBUS,
.flags = IORESOURCE_IRQ,
},
};
static struct mfd_cell tahvo_devs[] = {
{
.name = "tahvo-usb",
.resources = tahvo_usb_res,
.num_resources = ARRAY_SIZE(tahvo_usb_res),
},
};
static struct regmap_irq tahvo_irqs[] = {
[TAHVO_INT_VBUS] = {
.mask = 1 << TAHVO_INT_VBUS,
}
};
static struct regmap_irq_chip tahvo_irq_chip = {
.name = "TAHVO",
.irqs = tahvo_irqs,
.num_irqs = ARRAY_SIZE(tahvo_irqs),
.num_regs = 1,
.status_base = RETU_REG_IDR,
.mask_base = TAHVO_REG_IMR,
.ack_base = RETU_REG_IDR,
};
static const struct retu_data {
char *chip_name;
char *companion_name;
struct regmap_irq_chip *irq_chip;
struct mfd_cell *children;
int nchildren;
} retu_data[] = {
[0] = {
.chip_name = "Retu",
.companion_name = "Vilma",
.irq_chip = &retu_irq_chip,
.children = retu_devs,
.nchildren = ARRAY_SIZE(retu_devs),
},
[1] = {
.chip_name = "Tahvo",
.companion_name = "Betty",
.irq_chip = &tahvo_irq_chip,
.children = tahvo_devs,
.nchildren = ARRAY_SIZE(tahvo_devs),
}
};
int retu_read(struct retu_dev *rdev, u8 reg) int retu_read(struct retu_dev *rdev, u8 reg)
{ {
int ret; int ret;
...@@ -173,9 +230,14 @@ static struct regmap_config retu_config = { ...@@ -173,9 +230,14 @@ static struct regmap_config retu_config = {
static int retu_probe(struct i2c_client *i2c, const struct i2c_device_id *id) static int retu_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
{ {
struct retu_data const *rdat;
struct retu_dev *rdev; struct retu_dev *rdev;
int ret; int ret;
if (i2c->addr > ARRAY_SIZE(retu_data))
return -ENODEV;
rdat = &retu_data[i2c->addr - 1];
rdev = devm_kzalloc(&i2c->dev, sizeof(*rdev), GFP_KERNEL); rdev = devm_kzalloc(&i2c->dev, sizeof(*rdev), GFP_KERNEL);
if (rdev == NULL) if (rdev == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -190,25 +252,27 @@ static int retu_probe(struct i2c_client *i2c, const struct i2c_device_id *id) ...@@ -190,25 +252,27 @@ static int retu_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
ret = retu_read(rdev, RETU_REG_ASICR); ret = retu_read(rdev, RETU_REG_ASICR);
if (ret < 0) { if (ret < 0) {
dev_err(rdev->dev, "could not read Retu revision: %d\n", ret); dev_err(rdev->dev, "could not read %s revision: %d\n",
rdat->chip_name, ret);
return ret; return ret;
} }
dev_info(rdev->dev, "Retu%s v%d.%d found\n", dev_info(rdev->dev, "%s%s%s v%d.%d found\n", rdat->chip_name,
(ret & RETU_REG_ASICR_VILMA) ? " & Vilma" : "", (ret & RETU_REG_ASICR_VILMA) ? " & " : "",
(ret & RETU_REG_ASICR_VILMA) ? rdat->companion_name : "",
(ret >> 4) & 0x7, ret & 0xf); (ret >> 4) & 0x7, ret & 0xf);
/* Mask all RETU interrupts. */ /* Mask all interrupts. */
ret = retu_write(rdev, RETU_REG_IMR, 0xffff); ret = retu_write(rdev, rdat->irq_chip->mask_base, 0xffff);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = regmap_add_irq_chip(rdev->regmap, i2c->irq, IRQF_ONESHOT, -1, ret = regmap_add_irq_chip(rdev->regmap, i2c->irq, IRQF_ONESHOT, -1,
&retu_irq_chip, &rdev->irq_data); rdat->irq_chip, &rdev->irq_data);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = mfd_add_devices(rdev->dev, -1, retu_devs, ARRAY_SIZE(retu_devs), ret = mfd_add_devices(rdev->dev, -1, rdat->children, rdat->nchildren,
NULL, regmap_irq_chip_get_base(rdev->irq_data), NULL, regmap_irq_chip_get_base(rdev->irq_data),
NULL); NULL);
if (ret < 0) { if (ret < 0) {
...@@ -216,7 +280,7 @@ static int retu_probe(struct i2c_client *i2c, const struct i2c_device_id *id) ...@@ -216,7 +280,7 @@ static int retu_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
return ret; return ret;
} }
if (!pm_power_off) { if (i2c->addr == 1 && !pm_power_off) {
retu_pm_power_off = rdev; retu_pm_power_off = rdev;
pm_power_off = retu_power_off; pm_power_off = retu_power_off;
} }
...@@ -240,6 +304,7 @@ static int retu_remove(struct i2c_client *i2c) ...@@ -240,6 +304,7 @@ static int retu_remove(struct i2c_client *i2c)
static const struct i2c_device_id retu_id[] = { static const struct i2c_device_id retu_id[] = {
{ "retu-mfd", 0 }, { "retu-mfd", 0 },
{ "tahvo-mfd", 0 },
{ } { }
}; };
MODULE_DEVICE_TABLE(i2c, retu_id); MODULE_DEVICE_TABLE(i2c, retu_id);
......
/* /*
* Retu MFD driver interface * Retu/Tahvo MFD driver interface
* *
* This file is subject to the terms and conditions of the GNU General * This file is subject to the terms and conditions of the GNU General
* Public License. See the file "COPYING" in the main directory of this * Public License. See the file "COPYING" in the main directory of this
...@@ -19,4 +19,10 @@ int retu_write(struct retu_dev *, u8, u16); ...@@ -19,4 +19,10 @@ int retu_write(struct retu_dev *, u8, u16);
#define RETU_REG_CC1 0x0d /* Common control register 1 */ #define RETU_REG_CC1 0x0d /* Common control register 1 */
#define RETU_REG_STATUS 0x16 /* Status register */ #define RETU_REG_STATUS 0x16 /* Status register */
/* Interrupt sources */
#define TAHVO_INT_VBUS 0 /* VBUS state */
/* Interrupt status */
#define TAHVO_STAT_VBUS (1 << TAHVO_INT_VBUS)
#endif /* __LINUX_MFD_RETU_H */ #endif /* __LINUX_MFD_RETU_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment