|  | @@ -0,0 +1,86 @@
 | 
	
		
			
				|  |  | +/* arch/arm/plat-samsung/adc.c
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * Copyright (c) 2008 Simtec Electronics
 | 
	
		
			
				|  |  | + *	http://armlinux.simtec.co.uk/
 | 
	
		
			
				|  |  | + *	Ben Dooks <ben@simtec.co.uk>, <ben-linux@fluff.org>
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * Samsung ADC device core
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * 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.
 | 
	
		
			
				|  |  | +*/
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#include <linux/module.h>
 | 
	
		
			
				|  |  | +#include <linux/kernel.h>
 | 
	
		
			
				|  |  | +#include <linux/platform_device.h>
 | 
	
		
			
				|  |  | +#include <linux/sched.h>
 | 
	
		
			
				|  |  | +#include <linux/list.h>
 | 
	
		
			
				|  |  | +#include <linux/slab.h>
 | 
	
		
			
				|  |  | +#include <linux/err.h>
 | 
	
		
			
				|  |  | +#include <linux/clk.h>
 | 
	
		
			
				|  |  | +#include <linux/interrupt.h>
 | 
	
		
			
				|  |  | +#include <linux/io.h>
 | 
	
		
			
				|  |  | +#include <linux/regulator/consumer.h>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#include <plat/regs-adc.h>
 | 
	
		
			
				|  |  | +#include <plat/adc.h>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/* This driver is designed to control the usage of the ADC block between
 | 
	
		
			
				|  |  | + * the touchscreen and any other drivers that may need to use it, such as
 | 
	
		
			
				|  |  | + * the hwmon driver.
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * Priority will be given to the touchscreen driver, but as this itself is
 | 
	
		
			
				|  |  | + * rate limited it should not starve other requests which are processed in
 | 
	
		
			
				|  |  | + * order that they are received.
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * Each user registers to get a client block which uniquely identifies it
 | 
	
		
			
				|  |  | + * and stores information such as the necessary functions to callback when
 | 
	
		
			
				|  |  | + * action is required.
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +enum s3c_cpu_type {
 | 
	
		
			
				|  |  | +	TYPE_ADCV1, /* S3C24XX */
 | 
	
		
			
				|  |  | +	TYPE_ADCV11, /* S3C2443 */
 | 
	
		
			
				|  |  | +	TYPE_ADCV12, /* S3C2416, S3C2450 */
 | 
	
		
			
				|  |  | +	TYPE_ADCV2, /* S3C64XX, S5P64X0, S5PC100 */
 | 
	
		
			
				|  |  | +	TYPE_ADCV3, /* S5PV210, S5PC110, EXYNOS4210 */
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +struct s3c_adc_client {
 | 
	
		
			
				|  |  | +	struct platform_device	*pdev;
 | 
	
		
			
				|  |  | +	struct list_head	 pend;
 | 
	
		
			
				|  |  | +	wait_queue_head_t	*wait;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	unsigned int		 nr_samples;
 | 
	
		
			
				|  |  | +	int			 result;
 | 
	
		
			
				|  |  | +	unsigned char		 is_ts;
 | 
	
		
			
				|  |  | +	unsigned char		 channel;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	void	(*select_cb)(struct s3c_adc_client *c, unsigned selected);
 | 
	
		
			
				|  |  | +	void	(*convert_cb)(struct s3c_adc_client *c,
 | 
	
		
			
				|  |  | +			      unsigned val1, unsigned val2,
 | 
	
		
			
				|  |  | +			      unsigned *samples_left);
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +struct adc_device {
 | 
	
		
			
				|  |  | +	struct platform_device	*pdev;
 | 
	
		
			
				|  |  | +	struct platform_device	*owner;
 | 
	
		
			
				|  |  | +	struct clk		*clk;
 | 
	
		
			
				|  |  | +	struct s3c_adc_client	*cur;
 | 
	
		
			
				|  |  | +	struct s3c_adc_client	*ts_pend;
 | 
	
		
			
				|  |  | +	void __iomem		*regs;
 | 
	
		
			
				|  |  | +	spinlock_t		 lock;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	unsigned int		 prescale;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	int			 irq;
 | 
	
		
			
				|  |  | +	struct regulator	*vdd;
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +static struct adc_device *adc_dev;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +static LIST_HEAD(adc_pending);	/* protected by adc_device.lock */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#define adc_dbg(_adc, msg...) dev_dbg(&(_adc)->pdev->dev, msg)
 | 
	
		
			
				|  |  | +
 |