averageDataMemoryDefinition.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* arch/arm/plat-samsung/adc.c
  2. *
  3. * Copyright (c) 2008 Simtec Electronics
  4. * http://armlinux.simtec.co.uk/
  5. * Ben Dooks <ben@simtec.co.uk>, <ben-linux@fluff.org>
  6. *
  7. * Samsung ADC device core
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License.
  12. */
  13. #include <linux/module.h>
  14. #include <linux/kernel.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/sched.h>
  17. #include <linux/list.h>
  18. #include <linux/slab.h>
  19. #include <linux/err.h>
  20. #include <linux/clk.h>
  21. #include <linux/interrupt.h>
  22. #include <linux/io.h>
  23. #include <linux/regulator/consumer.h>
  24. #include <plat/regs-adc.h>
  25. #include <plat/adc.h>
  26. /* This driver is designed to control the usage of the ADC block between
  27. * the touchscreen and any other drivers that may need to use it, such as
  28. * the hwmon driver.
  29. *
  30. * Priority will be given to the touchscreen driver, but as this itself is
  31. * rate limited it should not starve other requests which are processed in
  32. * order that they are received.
  33. *
  34. * Each user registers to get a client block which uniquely identifies it
  35. * and stores information such as the necessary functions to callback when
  36. * action is required.
  37. */
  38. enum s3c_cpu_type {
  39. TYPE_ADCV1, /* S3C24XX */
  40. TYPE_ADCV11, /* S3C2443 */
  41. TYPE_ADCV12, /* S3C2416, S3C2450 */
  42. TYPE_ADCV2, /* S3C64XX, S5P64X0, S5PC100 */
  43. TYPE_ADCV3, /* S5PV210, S5PC110, EXYNOS4210 */
  44. };
  45. struct s3c_adc_client {
  46. struct platform_device *pdev;
  47. struct list_head pend;
  48. wait_queue_head_t *wait;
  49. unsigned int nr_samples;
  50. int result;
  51. unsigned char is_ts;
  52. unsigned char channel;
  53. void (*select_cb)(struct s3c_adc_client *c, unsigned selected);
  54. void (*convert_cb)(struct s3c_adc_client *c,
  55. unsigned val1, unsigned val2,
  56. unsigned *samples_left);
  57. };
  58. struct adc_device {
  59. struct platform_device *pdev;
  60. struct platform_device *owner;
  61. struct clk *clk;
  62. struct s3c_adc_client *cur;
  63. struct s3c_adc_client *ts_pend;
  64. void __iomem *regs;
  65. spinlock_t lock;
  66. unsigned int prescale;
  67. int irq;
  68. struct regulator *vdd;
  69. };
  70. static struct adc_device *adc_dev;
  71. static LIST_HEAD(adc_pending); /* protected by adc_device.lock */
  72. #define adc_dbg(_adc, msg...) dev_dbg(&(_adc)->pdev->dev, msg)