2009/5/21 Ben Dooks <ben at simtec.co.uk> > > Add support for the ADC controller on the S3C > series of processors to drivers/hwmon for use with > hardware monitoring systems. > > Signed-off-by: Ben Dooks <ben at simtec.co.uk> > > Index: linux.git/drivers/hwmon/Kconfig > =================================================================== > --- linux.git.orig/drivers/hwmon/Kconfig ? ? ? ?2009-05-20 22:02:06.000000000 +0100 > +++ linux.git/drivers/hwmon/Kconfig ? ? 2009-05-20 22:02:43.000000000 +0100 > @@ -702,6 +702,16 @@ config SENSORS_SHT15 > ? ? ? ? ?This driver can also be built as a module. ?If so, the module > ? ? ? ? ?will be called sht15. > > +config SENSORS_S3C_ADC > + ? ? ? tristate "S3C24XX/S3C64XX Inbuilt ADC" > + ? ? ? depends on HWMON && (ARCH_S3C2410 || ARCH_S3C64XX) > + ? ? ? help > + ? ? ? ? If you say yes here you get support for the on-board ADCs of > + ? ? ? ? the Samsung S3C24XX or S3C64XX series of SoC > + > + ? ? ? ? This driver can also be built as a module. If so, the module > + ? ? ? ? will be called s3c-adc. > + > ?config SENSORS_SIS5595 > ? ? ? ?tristate "Silicon Integrated Systems Corp. SiS5595" > ? ? ? ?depends on PCI > Index: linux.git/drivers/hwmon/Makefile > =================================================================== > --- linux.git.orig/drivers/hwmon/Makefile ? ? ? 2009-05-20 22:02:06.000000000 +0100 > +++ linux.git/drivers/hwmon/Makefile ? ?2009-05-20 22:02:43.000000000 +0100 > @@ -76,6 +76,7 @@ obj-$(CONFIG_SENSORS_MAX6650) += max6650 > ?obj-$(CONFIG_SENSORS_PC87360) ?+= pc87360.o > ?obj-$(CONFIG_SENSORS_PC87427) ?+= pc87427.o > ?obj-$(CONFIG_SENSORS_PCF8591) ?+= pcf8591.o > +obj-$(CONFIG_SENSORS_S3C_ADC) ?+= s3c-adc.o > ?obj-$(CONFIG_SENSORS_SHT15) ? ?+= sht15.o > ?obj-$(CONFIG_SENSORS_SIS5595) ?+= sis5595.o > ?obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o > Index: linux.git/drivers/hwmon/s3c-adc.c > =================================================================== > --- /dev/null ? 1970-01-01 00:00:00.000000000 +0000 > +++ linux.git/drivers/hwmon/s3c-adc.c ? 2009-05-20 22:20:32.000000000 +0100 > @@ -0,0 +1,371 @@ > +/* linux/drivers/hwmon/s3c-adc.c > + * > + * Copyright (C) 2005, 2008, 2009 Simtec Electronics > + * ? ? http://armlinux.simtec.co.uk/ > + * ? ? Ben Dooks <ben at simtec.co.uk> > + * > + * S3C24XX/S3C64XX ADC hwmon support > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License version 2 as > + * published by the Free Software Foundation. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ?See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program; if not, write to the Free Software > + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ?02111-1307 ?USA > +*/ > + > +#include <linux/module.h> > +#include <linux/slab.h> > +#include <linux/delay.h> > +#include <linux/io.h> > +#include <linux/init.h> > +#include <linux/err.h> > +#include <linux/clk.h> > +#include <linux/interrupt.h> > +#include <linux/platform_device.h> > + > +#include <linux/hwmon.h> > +#include <linux/hwmon-sysfs.h> > + > +#include <plat/adc.h> > +#include <plat/hwmon.h> > + > +/** > + * struct s3c_hwmon - ADC hwmon client information > + * @lock: Access lock for conversion. > + * @wait: Wait queue for conversions to complete. > + * @client: The client we registered with the S3C ADC core. > + * @dev: The platform device we bound to. > + * @hwmon_dev: The hwmon device we created. > + * @in_attr: The device attributes we created. > +*/ > +struct s3c_hwmon { > + ? ? ? struct semaphore ? ? ? ?lock; > + ? ? ? wait_queue_head_t ? ? ? wait; > + ? ? ? int ? ? ? ? ? ? ? ? ? ? val; > + > + ? ? ? struct s3c_hwmon_client *client; > + ? ? ? struct platform_device ?*dev; > + ? ? ? struct device ? ? ? ? ? *hwmon_dev; > + > + ? ? ? struct sensor_device_attribute *in_attr[8]; > +}; > + > +static inline struct s3c_hwmon *dev_to_ourhwmon(struct platform_device *dev) > +{ > + ? ? ? return (struct s3c_hwmon *)platform_get_drvdata(dev); > +} > + > +static struct s3c_hwmon *done_adc; > + > +/** > + * s3c_hwmon_adcdone - ADC core callback > + * @value: The value that we got from the ADC core > + * @ignore: Only used for the touchscreen client. > + * @left: The number of conversions left (not used here). > + * > + * This is called when the ADC has finished its conversion to > + * inform us of the result. > + */ > +static void s3c_hwmon_adcdone(unsigned value, unsigned ignore, unsigned *left) > +{ > + ? ? ? struct s3c_hwmon *adc = done_adc; > + > + ? ? ? hwmon->val = value; > + ? ? ? wake_up(&hwmon->wait); The variable should be 'adc'?