From 8335be6be5033ca548bd0231b3d0c5db392e5bec Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Fri, 25 Jun 2010 20:17:16 +0200 Subject: glamo-core: only disable non-disabled engines on suspend --- drivers/mfd/glamo-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/mfd/glamo-core.c') diff --git a/drivers/mfd/glamo-core.c b/drivers/mfd/glamo-core.c index 135856af1ee..af50b82981a 100644 --- a/drivers/mfd/glamo-core.c +++ b/drivers/mfd/glamo-core.c @@ -1163,7 +1163,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); } -- cgit v1.2.3 From b02fa027be49b9d9bc9642b2aa08dc2f3c7e32ec Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Fri, 25 Jun 2010 20:17:17 +0200 Subject: glamo-core: fix registers in init script --- drivers/mfd/glamo-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/mfd/glamo-core.c') diff --git a/drivers/mfd/glamo-core.c b/drivers/mfd/glamo-core.c index af50b82981a..d7bcce3ecd7 100644 --- a/drivers/mfd/glamo-core.c +++ b/drivers/mfd/glamo-core.c @@ -828,8 +828,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 }, -- cgit v1.2.3 From f81a8f9f0982decb3932733efb20620bf642a7d6 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Fri, 25 Jun 2010 20:17:18 +0200 Subject: glamo-core: initialize engine states as disabled This should fix random init failures such as white screen on boot. --- drivers/mfd/glamo-core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers/mfd/glamo-core.c') diff --git a/drivers/mfd/glamo-core.c b/drivers/mfd/glamo-core.c index d7bcce3ecd7..d3cd3714493 100644 --- a/drivers/mfd/glamo-core.c +++ b/drivers/mfd/glamo-core.c @@ -901,7 +901,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 +909,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; -- cgit v1.2.3 From b5e796d3912e84219d783f2c9c15bfd178821e12 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Fri, 25 Jun 2010 20:17:19 +0200 Subject: glamo-core: get rid of unused glamo_reg_{read, write}_batch --- drivers/mfd/glamo-core.c | 34 ---------------------------------- 1 file changed, 34 deletions(-) (limited to 'drivers/mfd/glamo-core.c') diff --git a/drivers/mfd/glamo-core.c b/drivers/mfd/glamo-core.c index d3cd3714493..e88e6c60533 100644 --- a/drivers/mfd/glamo-core.c +++ b/drivers/mfd/glamo-core.c @@ -175,40 +175,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 ***********************************************************************/ -- cgit v1.2.3 From 3ab0d545a0b24811883eec3e9b43fa22645f9c17 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Fri, 25 Jun 2010 19:39:30 +0200 Subject: glamo-core: use debugfs instead of sysfs for the 'regs' node Use debugfs, which is better-suited than sysfs for the 'regs' node. Also change the expected format from decimal to hexadecimal numbers. --- drivers/mfd/glamo-core.c | 90 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 66 insertions(+), 24 deletions(-) (limited to 'drivers/mfd/glamo-core.c') diff --git a/drivers/mfd/glamo-core.c b/drivers/mfd/glamo-core.c index e88e6c60533..05bc7375b3e 100644 --- a/drivers/mfd/glamo-core.c +++ b/drivers/mfd/glamo-core.c @@ -40,6 +40,9 @@ #include #include #include +#include +#include +#include #include @@ -317,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", ®, &val) != 2) + return -EFAULT; - sscanf(buf, "%u %u", ®, &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 DEVICE_ATTR(regs, 0644, regs_read, regs_write); +static int debugfs_open_file(struct inode *inode, struct file *file) +{ + return single_open(file, glamo_show_regs, inode->i_private); +} + +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; @@ -370,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; @@ -935,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, @@ -1009,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); -- cgit v1.2.3