Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
common.c
Go to the documentation of this file.
1 /*
2  * Atheros AR71XX/AR724X/AR913X common routines
3  *
4  * Copyright (C) 2010-2011 Jaiganesh Narayanan <[email protected]>
5  * Copyright (C) 2008-2011 Gabor Juhos <[email protected]>
6  * Copyright (C) 2008 Imre Kaloz <[email protected]>
7  *
8  * Parts of this file are based on Atheros' 2.6.15/2.6.31 BSP
9  *
10  * This program is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU General Public License version 2 as published
12  * by the Free Software Foundation.
13  */
14 
15 #include <linux/kernel.h>
16 #include <linux/module.h>
17 #include <linux/types.h>
18 #include <linux/spinlock.h>
19 
20 #include <asm/mach-ath79/ath79.h>
22 #include "common.h"
23 
24 static DEFINE_SPINLOCK(ath79_device_reset_lock);
25 
28 
31 
34 
36 unsigned int ath79_soc_rev;
37 
42 
44 {
45  void __iomem *flush_reg = ath79_ddr_base + reg;
46 
47  /* Flush the DDR write buffer. */
48  __raw_writel(0x1, flush_reg);
49  while (__raw_readl(flush_reg) & 0x1)
50  ;
51 
52  /* It must be run twice. */
53  __raw_writel(0x1, flush_reg);
54  while (__raw_readl(flush_reg) & 0x1)
55  ;
56 }
58 
60 {
61  unsigned long flags;
62  u32 reg;
63  u32 t;
64 
65  if (soc_is_ar71xx())
67  else if (soc_is_ar724x())
69  else if (soc_is_ar913x())
71  else if (soc_is_ar933x())
73  else if (soc_is_ar934x())
75  else
76  BUG();
77 
78  spin_lock_irqsave(&ath79_device_reset_lock, flags);
79  t = ath79_reset_rr(reg);
80  ath79_reset_wr(reg, t | mask);
81  spin_unlock_irqrestore(&ath79_device_reset_lock, flags);
82 }
84 
86 {
87  unsigned long flags;
88  u32 reg;
89  u32 t;
90 
91  if (soc_is_ar71xx())
93  else if (soc_is_ar724x())
95  else if (soc_is_ar913x())
97  else if (soc_is_ar933x())
99  else if (soc_is_ar934x())
101  else
102  BUG();
103 
104  spin_lock_irqsave(&ath79_device_reset_lock, flags);
105  t = ath79_reset_rr(reg);
106  ath79_reset_wr(reg, t & ~mask);
107  spin_unlock_irqrestore(&ath79_device_reset_lock, flags);
108 }