From e98bc767ef25c9770063c9a52fedffeb13fb4d00 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 11 Sep 2005 10:27:23 +0100 Subject: [PATCH] --- yaml --- r: 8495 b: refs/heads/master c: 48c92022ad264cb8084cee78a499f183b264e45f h: refs/heads/master i: 8493: c8b043c1be2c901a54a928e5d4681bc50e73060c 8491: e74b06cf4bf2e51401356a8c5d5a3cdf2bd8c32d 8487: 56817625ee9d51f927aa9d1747bfeda3eec94a3f 8479: 683e21877c009fc4a3c10d3d7fe296f06abfdd2b v: v3 --- [refs] | 2 +- trunk/drivers/mfd/Makefile | 4 ++ trunk/drivers/mfd/ucb1x00-assabet.c | 73 +++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 trunk/drivers/mfd/ucb1x00-assabet.c diff --git a/[refs] b/[refs] index d97573f2dde8..a9ac0acaaf3b 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: acb45439a89c6830349c02405f00a7208db0a66b +refs/heads/master: 48c92022ad264cb8084cee78a499f183b264e45f diff --git a/trunk/drivers/mfd/Makefile b/trunk/drivers/mfd/Makefile index a05cd1599a70..adb29b5368a8 100644 --- a/trunk/drivers/mfd/Makefile +++ b/trunk/drivers/mfd/Makefile @@ -6,3 +6,7 @@ obj-$(CONFIG_MCP) += mcp-core.o obj-$(CONFIG_MCP_SA11X0) += mcp-sa11x0.o obj-$(CONFIG_MCP_UCB1200) += ucb1x00-core.o obj-$(CONFIG_MCP_UCB1200_TS) += ucb1x00-ts.o + +ifeq ($(CONFIG_SA1100_ASSABET),y) +obj-$(CONFIG_MCP_UCB1200) += ucb1x00-assabet.o +endif diff --git a/trunk/drivers/mfd/ucb1x00-assabet.c b/trunk/drivers/mfd/ucb1x00-assabet.c new file mode 100644 index 000000000000..e325fa71f38b --- /dev/null +++ b/trunk/drivers/mfd/ucb1x00-assabet.c @@ -0,0 +1,73 @@ +/* + * linux/drivers/mfd/ucb1x00-assabet.c + * + * Copyright (C) 2001-2003 Russell King, All Rights Reserved. + * + * 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; either version 2 of the License. + * + * We handle the machine-specific bits of the UCB1x00 driver here. + */ +#include +#include +#include +#include +#include + +#include + +#include "ucb1x00.h" + +#define UCB1X00_ATTR(name,input)\ +static ssize_t name##_show(struct class_device *dev, char *buf) \ +{ \ + struct ucb1x00 *ucb = classdev_to_ucb1x00(dev); \ + int val; \ + ucb1x00_adc_enable(ucb); \ + val = ucb1x00_adc_read(ucb, input, UCB_NOSYNC); \ + ucb1x00_adc_disable(ucb); \ + return sprintf(buf, "%d\n", val); \ +} \ +static CLASS_DEVICE_ATTR(name,0444,name##_show,NULL) + +UCB1X00_ATTR(vbatt, UCB_ADC_INP_AD1); +UCB1X00_ATTR(vcharger, UCB_ADC_INP_AD0); +UCB1X00_ATTR(batt_temp, UCB_ADC_INP_AD2); + +static int ucb1x00_assabet_add(struct ucb1x00_dev *dev) +{ + class_device_create_file(&dev->ucb->cdev, &class_device_attr_vbatt); + class_device_create_file(&dev->ucb->cdev, &class_device_attr_vcharger); + class_device_create_file(&dev->ucb->cdev, &class_device_attr_batt_temp); + return 0; +} + +static void ucb1x00_assabet_remove(struct ucb1x00_dev *dev) +{ + class_device_remove_file(&dev->ucb->cdev, &class_device_attr_batt_temp); + class_device_remove_file(&dev->ucb->cdev, &class_device_attr_vcharger); + class_device_remove_file(&dev->ucb->cdev, &class_device_attr_vbatt); +} + +static struct ucb1x00_driver ucb1x00_assabet_driver = { + .add = ucb1x00_assabet_add, + .remove = ucb1x00_assabet_remove, +}; + +static int __init ucb1x00_assabet_init(void) +{ + return ucb1x00_register_driver(&ucb1x00_assabet_driver); +} + +static void __exit ucb1x00_assabet_exit(void) +{ + ucb1x00_unregister_driver(&ucb1x00_assabet_driver); +} + +module_init(ucb1x00_assabet_init); +module_exit(ucb1x00_assabet_exit); + +MODULE_AUTHOR("Russell King "); +MODULE_DESCRIPTION("Assabet noddy testing only example ADC driver"); +MODULE_LICENSE("GPL");