temperatureVariance.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* linux/arch/arm/plat-s3c64xx/dma.c
  2. *
  3. * Copyright 2009 Openmoko, Inc.
  4. * Copyright 2009 Simtec Electronics
  5. * Ben Dooks <ben@simtec.co.uk>
  6. * http://armlinux.simtec.co.uk/
  7. *
  8. * S3C64XX DMA core
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/module.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/dmapool.h>
  18. #include <linux/device.h>
  19. #include <linux/errno.h>
  20. #include <linux/slab.h>
  21. #include <linux/delay.h>
  22. #include <linux/clk.h>
  23. #include <linux/err.h>
  24. #include <linux/io.h>
  25. #include <mach/dma.h>
  26. #include <mach/map.h>
  27. #include <mach/irqs.h>
  28. #include <mach/regs-sys.h>
  29. #include <asm/hardware/pl080.h>
  30. /* dma channel state information */
  31. struct s3c64xx_dmac {
  32. struct device dev;
  33. struct clk *clk;
  34. void __iomem *regs;
  35. struct s3c2410_dma_chan *channels;
  36. enum dma_ch chanbase;
  37. };
  38. /* pool to provide LLI buffers */
  39. static struct dma_pool *dma_pool;
  40. /* Debug configuration and code */
  41. static unsigned char debug_show_buffs = 0;
  42. static void dbg_showchan(struct s3c2410_dma_chan *chan)
  43. {
  44. pr_debug("DMA%d: %08x->%08x L %08x C %08x,%08x S %08x\n",
  45. chan->number,
  46. readl(chan->regs + PL080_CH_SRC_ADDR),
  47. readl(chan->regs + PL080_CH_DST_ADDR),
  48. readl(chan->regs + PL080_CH_LLI),
  49. readl(chan->regs + PL080_CH_CONTROL),
  50. readl(chan->regs + PL080S_CH_CONTROL2),
  51. readl(chan->regs + PL080S_CH_CONFIG));
  52. }
  53. static void show_lli(struct pl080s_lli *lli)
  54. {
  55. pr_debug("LLI[%p] %08x->%08x, NL %08x C %08x,%08x\n",
  56. lli, lli->src_addr, lli->dst_addr, lli->next_lli,
  57. lli->control0, lli->control1);
  58. }
  59. static void dbg_showbuffs(struct s3c2410_dma_chan *chan)
  60. {
  61. struct s3c64xx_dma_buff *ptr;
  62. struct s3c64xx_dma_buff *end;
  63. pr_debug("DMA%d: buffs next %p, curr %p, end %p\n",
  64. chan->number, chan->next, chan->curr, chan->end);
  65. ptr = chan->next;
  66. end = chan->end;
  67. if (debug_show_buffs) {
  68. for (; ptr != NULL; ptr = ptr->next) {
  69. pr_debug("DMA%d: %08x ",
  70. chan->number, ptr->lli_dma);
  71. show_lli(ptr->lli);
  72. }
  73. }
  74. }
  75. /* End of Debug */
  76. static struct s3c2410_dma_chan *s3c64xx_dma_map_channel(unsigned int channel)
  77. {
  78. struct s3c2410_dma_chan *chan;
  79. unsigned int start, offs;
  80. start = 0;
  81. if (channel >= DMACH_PCM1_TX)
  82. start = 8;
  83. for (offs = 0; offs < 8; offs++) {
  84. chan = &s3c2410_chans[start + offs];
  85. if (!chan->in_use)
  86. goto found;
  87. }
  88. return NULL;
  89. found:
  90. s3c_dma_chan_map[channel] = chan;
  91. return chan;
  92. }
  93. int s3c2410_dma_config(enum dma_ch channel, int xferunit)
  94. {
  95. struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
  96. if (chan == NULL)
  97. return -EINVAL;
  98. switch (xferunit) {
  99. case 1:
  100. chan->hw_width = 0;
  101. break;