| Russell King | 48c9202 | 2005-09-11 10:27:23 +0100 | [diff] [blame] | 1 | /* | 
 | 2 |  *  linux/drivers/mfd/ucb1x00-assabet.c | 
 | 3 |  * | 
 | 4 |  *  Copyright (C) 2001-2003 Russell King, All Rights Reserved. | 
 | 5 |  * | 
 | 6 |  * This program is free software; you can redistribute it and/or modify | 
 | 7 |  * it under the terms of the GNU General Public License as published by | 
 | 8 |  * the Free Software Foundation; either version 2 of the License. | 
 | 9 |  * | 
 | 10 |  *  We handle the machine-specific bits of the UCB1x00 driver here. | 
 | 11 |  */ | 
 | 12 | #include <linux/module.h> | 
 | 13 | #include <linux/init.h> | 
 | 14 | #include <linux/fs.h> | 
 | 15 | #include <linux/proc_fs.h> | 
 | 16 | #include <linux/device.h> | 
| Thomas Kunze | c8602ed | 2009-02-10 14:54:57 +0100 | [diff] [blame] | 17 | #include <linux/mfd/ucb1x00.h> | 
| Russell King | 48c9202 | 2005-09-11 10:27:23 +0100 | [diff] [blame] | 18 |  | 
| Russell King | dcea83a | 2008-11-29 11:40:28 +0000 | [diff] [blame] | 19 | #include <mach/dma.h> | 
| Russell King | 48c9202 | 2005-09-11 10:27:23 +0100 | [diff] [blame] | 20 |  | 
| Russell King | 48c9202 | 2005-09-11 10:27:23 +0100 | [diff] [blame] | 21 |  | 
 | 22 | #define UCB1X00_ATTR(name,input)\ | 
| Russell King | cd4c1eb | 2008-01-28 10:59:09 +0000 | [diff] [blame] | 23 | static ssize_t name##_show(struct device *dev, struct device_attribute *attr, \ | 
| Tony Jones | 0c55445 | 2007-09-25 02:03:03 +0200 | [diff] [blame] | 24 | 			   char *buf)	\ | 
| Russell King | 48c9202 | 2005-09-11 10:27:23 +0100 | [diff] [blame] | 25 | {								\ | 
 | 26 | 	struct ucb1x00 *ucb = classdev_to_ucb1x00(dev);		\ | 
 | 27 | 	int val;						\ | 
 | 28 | 	ucb1x00_adc_enable(ucb);				\ | 
 | 29 | 	val = ucb1x00_adc_read(ucb, input, UCB_NOSYNC);		\ | 
 | 30 | 	ucb1x00_adc_disable(ucb);				\ | 
 | 31 | 	return sprintf(buf, "%d\n", val);			\ | 
 | 32 | }								\ | 
| Tony Jones | 0c55445 | 2007-09-25 02:03:03 +0200 | [diff] [blame] | 33 | static DEVICE_ATTR(name,0444,name##_show,NULL) | 
| Russell King | 48c9202 | 2005-09-11 10:27:23 +0100 | [diff] [blame] | 34 |  | 
 | 35 | UCB1X00_ATTR(vbatt, UCB_ADC_INP_AD1); | 
 | 36 | UCB1X00_ATTR(vcharger, UCB_ADC_INP_AD0); | 
 | 37 | UCB1X00_ATTR(batt_temp, UCB_ADC_INP_AD2); | 
 | 38 |  | 
 | 39 | static int ucb1x00_assabet_add(struct ucb1x00_dev *dev) | 
 | 40 | { | 
| Russell King | cd4c1eb | 2008-01-28 10:59:09 +0000 | [diff] [blame] | 41 | 	device_create_file(&dev->ucb->dev, &dev_attr_vbatt); | 
 | 42 | 	device_create_file(&dev->ucb->dev, &dev_attr_vcharger); | 
 | 43 | 	device_create_file(&dev->ucb->dev, &dev_attr_batt_temp); | 
| Russell King | 48c9202 | 2005-09-11 10:27:23 +0100 | [diff] [blame] | 44 | 	return 0; | 
 | 45 | } | 
 | 46 |  | 
 | 47 | static void ucb1x00_assabet_remove(struct ucb1x00_dev *dev) | 
 | 48 | { | 
| Russell King | cd4c1eb | 2008-01-28 10:59:09 +0000 | [diff] [blame] | 49 | 	device_remove_file(&dev->ucb->dev, &dev_attr_batt_temp); | 
 | 50 | 	device_remove_file(&dev->ucb->dev, &dev_attr_vcharger); | 
 | 51 | 	device_remove_file(&dev->ucb->dev, &dev_attr_vbatt); | 
| Russell King | 48c9202 | 2005-09-11 10:27:23 +0100 | [diff] [blame] | 52 | } | 
 | 53 |  | 
 | 54 | static struct ucb1x00_driver ucb1x00_assabet_driver = { | 
 | 55 | 	.add	= ucb1x00_assabet_add, | 
 | 56 | 	.remove	= ucb1x00_assabet_remove, | 
 | 57 | }; | 
 | 58 |  | 
 | 59 | static int __init ucb1x00_assabet_init(void) | 
 | 60 | { | 
 | 61 | 	return ucb1x00_register_driver(&ucb1x00_assabet_driver); | 
 | 62 | } | 
 | 63 |  | 
 | 64 | static void __exit ucb1x00_assabet_exit(void) | 
 | 65 | { | 
 | 66 | 	ucb1x00_unregister_driver(&ucb1x00_assabet_driver); | 
 | 67 | } | 
 | 68 |  | 
 | 69 | module_init(ucb1x00_assabet_init); | 
 | 70 | module_exit(ucb1x00_assabet_exit); | 
 | 71 |  | 
 | 72 | MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>"); | 
 | 73 | MODULE_DESCRIPTION("Assabet noddy testing only example ADC driver"); | 
 | 74 | MODULE_LICENSE("GPL"); |