aboutsummaryrefslogtreecommitdiff
path: root/drivers/mfd
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2010-07-03 19:15:08 +0200
committerLars-Peter Clausen <lars@metafoo.de>2010-07-03 19:15:08 +0200
commitaa0f646273035824cc033aa229380f1a27c0f4ed (patch)
tree6677cf96bda9d316754bda07615f008ad87de6f4 /drivers/mfd
parent4ce5f33cd4bcde2e25d50ae0880eb39213e2b6d2 (diff)
parent6650e90feca03fc8dc46fa4d8234f63377e7b80d (diff)
Merge branch 'glamo-2.6.34' into om-gta02-2.6.34om-gta02-2.6.34
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/glamo-core.c135
1 files changed, 73 insertions, 62 deletions
diff --git a/drivers/mfd/glamo-core.c b/drivers/mfd/glamo-core.c
index 135856af1ee..05bc7375b3e 100644
--- a/drivers/mfd/glamo-core.c
+++ b/drivers/mfd/glamo-core.c
@@ -40,6 +40,9 @@
#include <linux/mfd/glamo-core.h>
#include <linux/io.h>
#include <linux/slab.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
+#include <asm/uaccess.h>
#include <linux/pm.h>
@@ -175,40 +178,6 @@ static inline void __reg_clear_bit(struct glamo_core *glamo,
__reg_write(glamo, reg, tmp);
}
-static void __reg_write_batch(struct glamo_core *glamo, uint16_t reg,
- uint16_t count, uint16_t *values)
-{
- uint16_t end;
- for (end = reg + count * 2; reg < end; reg += 2, ++values)
- __reg_write(glamo, reg, *values);
-}
-
-static void __reg_read_batch(struct glamo_core *glamo, uint16_t reg,
- uint16_t count, uint16_t *values)
-{
- uint16_t end;
- for (end = reg + count * 2; reg < end; reg += 2, ++values)
- *values = __reg_read(glamo, reg);
-}
-
-void glamo_reg_write_batch(struct glamo_core *glamo, uint16_t reg,
- uint16_t count, uint16_t *values)
-{
- spin_lock(&glamo->lock);
- __reg_write_batch(glamo, reg, count, values);
- spin_unlock(&glamo->lock);
-}
-EXPORT_SYMBOL(glamo_reg_write_batch);
-
-void glamo_reg_read_batch(struct glamo_core *glamo, uint16_t reg,
- uint16_t count, uint16_t *values)
-{
- spin_lock(&glamo->lock);
- __reg_read_batch(glamo, reg, count, values);
- spin_unlock(&glamo->lock);
-}
-EXPORT_SYMBOL(glamo_reg_read_batch);
-
/***********************************************************************
* resources of sibling devices
***********************************************************************/
@@ -351,52 +320,68 @@ static void glamo_irq_demux_handler(unsigned int irq, struct irq_desc *desc)
}
/*
-sysfs
+debugfs
*/
-static ssize_t regs_write(struct device *dev, struct device_attribute *attr,
- const char *buf, size_t count)
+#ifdef CONFIG_DEBUG_FS
+static ssize_t debugfs_regs_write(struct file *file,
+ const char __user *user_buf,
+ size_t count, loff_t *ppos)
{
- struct glamo_core *glamo = dev_get_drvdata(dev);
+ struct glamo_core *glamo = ((struct seq_file *)file->private_data)->private;
+ char buf[14];
unsigned int reg;
unsigned int val;
+ int buf_size;
+
+ buf_size = min(count, sizeof(buf) - 1);
+ if (copy_from_user(buf, user_buf, buf_size))
+ return -EFAULT;
+ if (sscanf(buf, "%x %x", &reg, &val) != 2)
+ return -EFAULT;
- sscanf(buf, "%u %u", &reg, &val);
- printk(KERN_INFO"reg 0x%02x <-- 0x%04x\n",
- reg, val);
+ dev_info(&glamo->pdev->dev, "reg %#02x <-- %#04x\n", reg, val);
glamo_reg_write(glamo, reg, val);
return count;
}
-static ssize_t regs_read(struct device *dev, struct device_attribute *attr,
- char *buf)
+static int glamo_show_regs(struct seq_file *s, void *pos)
{
- struct glamo_core *glamo = dev_get_drvdata(dev);
+ struct glamo_core *glamo = s->private;
int i, n;
- char *end = buf;
const struct reg_range *rr = reg_range;
spin_lock(&glamo->lock);
-
for (i = 0; i < ARRAY_SIZE(reg_range); ++i, ++rr) {
if (!rr->dump)
continue;
- end += sprintf(end, "\n%s\n", rr->name);
+ seq_printf(s, "\n%s\n", rr->name);
for (n = rr->start; n < rr->start + rr->count; n += 2) {
if ((n & 15) == 0)
- end += sprintf(end, "\n%04X: ", n);
- end += sprintf(end, "%04x ", __reg_read(glamo, n));
+ seq_printf(s, "\n%04X: ", n);
+ seq_printf(s, "%04x ", __reg_read(glamo, n));
}
- end += sprintf(end, "\n");
+ seq_printf(s, "\n");
}
spin_unlock(&glamo->lock);
- return end - buf;
+ return 0;
+}
+
+static int debugfs_open_file(struct inode *inode, struct file *file)
+{
+ return single_open(file, glamo_show_regs, inode->i_private);
}
-static DEVICE_ATTR(regs, 0644, regs_read, regs_write);
+static const struct file_operations debugfs_regs_ops = {
+ .open = debugfs_open_file,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .write = debugfs_regs_write,
+ .release = single_release,
+};
struct glamo_engine_reg_set {
uint16_t reg;
@@ -404,6 +389,31 @@ struct glamo_engine_reg_set {
uint16_t mask_enabled;
};
+static void glamo_init_debugfs(struct glamo_core *glamo)
+{
+ glamo->debugfs_dir = debugfs_create_dir("glamo3362", NULL);
+ if (glamo->debugfs_dir)
+ debugfs_create_file("regs", S_IRUGO | S_IWUSR, glamo->debugfs_dir,
+ glamo, &debugfs_regs_ops);
+ else
+ dev_warn(&glamo->pdev->dev, "Failed to set up debugfs.\n");
+}
+
+static void glamo_exit_debugfs(struct glamo_core *glamo)
+{
+ if (glamo->debugfs_dir)
+ debugfs_remove_recursive(glamo->debugfs_dir);
+}
+#else
+static void glamo_init_debugfs(struct glamo_core *glamo)
+{
+}
+
+static void glamo_exit_debugfs(struct glamo_core *glamo)
+{
+}
+#endif
+
struct glamo_engine_desc {
const char *name;
uint16_t hostbus;
@@ -828,8 +838,8 @@ static const struct glamo_script glamo_init_script[] = {
* b7..b4 = 0 = no wait states on read or write
* b0 = 1 select PLL2 for Host interface, b1 = enable it
*/
- { GLAMO_REG_HOSTBUS(0), 0x0e03 /* this is replaced by script parser */ },
- { GLAMO_REG_HOSTBUS(1), 0x07ff }, /* TODO: Disable all */
+ { GLAMO_REG_HOSTBUS(1), 0x0e03 /* this is replaced by script parser */ },
+ { GLAMO_REG_HOSTBUS(2), 0x07ff }, /* TODO: Disable all */
{ GLAMO_REG_HOSTBUS(10), 0x0000 },
{ GLAMO_REG_HOSTBUS(11), 0x4000 },
{ GLAMO_REG_HOSTBUS(12), 0xf00e },
@@ -901,7 +911,7 @@ static int __devinit glamo_supported(struct glamo_core *glamo)
static int __devinit glamo_probe(struct platform_device *pdev)
{
- int ret = 0, irq, irq_base;
+ int ret = 0, n, irq, irq_base;
struct glamo_core *glamo;
struct resource *mem;
@@ -909,6 +919,9 @@ static int __devinit glamo_probe(struct platform_device *pdev)
if (!glamo)
return -ENOMEM;
+ for (n = 0; n < __NUM_GLAMO_ENGINES; n++)
+ glamo->engine_state[n] = GLAMO_ENGINE_DISABLED;
+
spin_lock_init(&glamo->lock);
glamo->pdev = pdev;
@@ -966,12 +979,8 @@ static int __devinit glamo_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, glamo);
- /* sysfs */
- ret = device_create_file(&pdev->dev, &dev_attr_regs);
- if (ret < 0) {
- dev_err(&pdev->dev, "Failed to create sysfs file\n");
- goto err_iounmap;
- }
+ /* debugfs */
+ glamo_init_debugfs(glamo);
/* init the chip with canned register set */
glamo_run_script(glamo, glamo_init_script,
@@ -1040,6 +1049,8 @@ static int __devexit glamo_remove(struct platform_device *pdev)
int irq;
int irq_base = glamo->irq_base;
+ glamo_exit_debugfs(glamo);
+
mfd_remove_devices(&pdev->dev);
disable_irq(glamo->irq);
@@ -1163,7 +1174,7 @@ static int glamo_suspend(struct device *dev)
/* take down each engine before we kill mem and pll */
for (n = 0; n < __NUM_GLAMO_ENGINES; n++) {
- if (glamo->engine_state != GLAMO_ENGINE_DISABLED)
+ if (glamo->engine_state[n] != GLAMO_ENGINE_DISABLED)
__glamo_engine_disable(glamo, n);
}