PageRenderTime 79ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 1ms

/target/linux/generic-2.4/patches/000-linux_mips.patch

https://github.com/hentel/openwrt
Patch | 18282 lines | 17606 code | 676 blank | 0 comment | 0 complexity | 4c5ad5e342013da98ffdacadb207c8c7 MD5 | raw file
Possible License(s): GPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. --- a/arch/mips/au1000/common/au1xxx_irqmap.c
  2. +++ b/arch/mips/au1000/common/au1xxx_irqmap.c
  3. @@ -172,14 +172,14 @@ au1xxx_irq_map_t au1xxx_ic0_map[] = {
  4. { AU1550_PSC1_INT, INTC_INT_HIGH_LEVEL, 0},
  5. { AU1550_PSC2_INT, INTC_INT_HIGH_LEVEL, 0},
  6. { AU1550_PSC3_INT, INTC_INT_HIGH_LEVEL, 0},
  7. - { AU1550_TOY_INT, INTC_INT_RISE_EDGE, 0 },
  8. - { AU1550_TOY_MATCH0_INT, INTC_INT_RISE_EDGE, 0 },
  9. - { AU1550_TOY_MATCH1_INT, INTC_INT_RISE_EDGE, 0 },
  10. - { AU1550_TOY_MATCH2_INT, INTC_INT_RISE_EDGE, 1 },
  11. - { AU1550_RTC_INT, INTC_INT_RISE_EDGE, 0 },
  12. - { AU1550_RTC_MATCH0_INT, INTC_INT_RISE_EDGE, 0 },
  13. - { AU1550_RTC_MATCH1_INT, INTC_INT_RISE_EDGE, 0 },
  14. - { AU1550_RTC_MATCH2_INT, INTC_INT_RISE_EDGE, 0 },
  15. + { AU1000_TOY_INT, INTC_INT_RISE_EDGE, 0 },
  16. + { AU1000_TOY_MATCH0_INT, INTC_INT_RISE_EDGE, 0 },
  17. + { AU1000_TOY_MATCH1_INT, INTC_INT_RISE_EDGE, 0 },
  18. + { AU1000_TOY_MATCH2_INT, INTC_INT_RISE_EDGE, 1 },
  19. + { AU1000_RTC_INT, INTC_INT_RISE_EDGE, 0 },
  20. + { AU1000_RTC_MATCH0_INT, INTC_INT_RISE_EDGE, 0 },
  21. + { AU1000_RTC_MATCH1_INT, INTC_INT_RISE_EDGE, 0 },
  22. + { AU1000_RTC_MATCH2_INT, INTC_INT_RISE_EDGE, 0 },
  23. { AU1550_NAND_INT, INTC_INT_RISE_EDGE, 0},
  24. { AU1550_USB_DEV_REQ_INT, INTC_INT_HIGH_LEVEL, 0 },
  25. { AU1550_USB_DEV_SUS_INT, INTC_INT_RISE_EDGE, 0 },
  26. @@ -200,14 +200,14 @@ au1xxx_irq_map_t au1xxx_ic0_map[] = {
  27. { AU1200_PSC1_INT, INTC_INT_HIGH_LEVEL, 0},
  28. { AU1200_AES_INT, INTC_INT_HIGH_LEVEL, 0},
  29. { AU1200_CAMERA_INT, INTC_INT_HIGH_LEVEL, 0},
  30. - { AU1200_TOY_INT, INTC_INT_RISE_EDGE, 0 },
  31. - { AU1200_TOY_MATCH0_INT, INTC_INT_RISE_EDGE, 0 },
  32. - { AU1200_TOY_MATCH1_INT, INTC_INT_RISE_EDGE, 0 },
  33. - { AU1200_TOY_MATCH2_INT, INTC_INT_RISE_EDGE, 1 },
  34. - { AU1200_RTC_INT, INTC_INT_RISE_EDGE, 0 },
  35. - { AU1200_RTC_MATCH0_INT, INTC_INT_RISE_EDGE, 0 },
  36. - { AU1200_RTC_MATCH1_INT, INTC_INT_RISE_EDGE, 0 },
  37. - { AU1200_RTC_MATCH2_INT, INTC_INT_RISE_EDGE, 0 },
  38. + { AU1000_TOY_INT, INTC_INT_RISE_EDGE, 0 },
  39. + { AU1000_TOY_MATCH0_INT, INTC_INT_RISE_EDGE, 0 },
  40. + { AU1000_TOY_MATCH1_INT, INTC_INT_RISE_EDGE, 0 },
  41. + { AU1000_TOY_MATCH2_INT, INTC_INT_RISE_EDGE, 1 },
  42. + { AU1000_RTC_INT, INTC_INT_RISE_EDGE, 0 },
  43. + { AU1000_RTC_MATCH0_INT, INTC_INT_RISE_EDGE, 0 },
  44. + { AU1000_RTC_MATCH1_INT, INTC_INT_RISE_EDGE, 0 },
  45. + { AU1000_RTC_MATCH2_INT, INTC_INT_RISE_EDGE, 0 },
  46. { AU1200_NAND_INT, INTC_INT_RISE_EDGE, 0},
  47. { AU1200_USB_INT, INTC_INT_HIGH_LEVEL, 0 },
  48. { AU1200_LCD_INT, INTC_INT_HIGH_LEVEL, 0},
  49. --- a/arch/mips/au1000/common/cputable.c
  50. +++ b/arch/mips/au1000/common/cputable.c
  51. @@ -39,7 +39,8 @@ struct cpu_spec cpu_specs[] = {
  52. { 0xffffffff, 0x02030203, "Au1100 BD", 0, 1 },
  53. { 0xffffffff, 0x02030204, "Au1100 BE", 0, 1 },
  54. { 0xffffffff, 0x03030200, "Au1550 AA", 0, 1 },
  55. - { 0xffffffff, 0x04030200, "Au1200 AA", 0, 1 },
  56. + { 0xffffffff, 0x04030200, "Au1200 AB", 0, 0 },
  57. + { 0xffffffff, 0x04030201, "Au1200 AC", 0, 0 },
  58. { 0x00000000, 0x00000000, "Unknown Au1xxx", 1, 0 },
  59. };
  60. --- a/arch/mips/au1000/common/dbdma.c
  61. +++ b/arch/mips/au1000/common/dbdma.c
  62. @@ -41,6 +41,8 @@
  63. #include <asm/au1xxx_dbdma.h>
  64. #include <asm/system.h>
  65. +#include <linux/module.h>
  66. +
  67. #if defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200)
  68. /*
  69. @@ -60,37 +62,10 @@ static spinlock_t au1xxx_dbdma_spin_lock
  70. */
  71. #define ALIGN_ADDR(x, a) ((((u32)(x)) + (a-1)) & ~(a-1))
  72. -static volatile dbdma_global_t *dbdma_gptr = (dbdma_global_t *)DDMA_GLOBAL_BASE;
  73. -static int dbdma_initialized;
  74. +static dbdma_global_t *dbdma_gptr = (dbdma_global_t *)DDMA_GLOBAL_BASE;
  75. +static int dbdma_initialized=0;
  76. static void au1xxx_dbdma_init(void);
  77. -typedef struct dbdma_device_table {
  78. - u32 dev_id;
  79. - u32 dev_flags;
  80. - u32 dev_tsize;
  81. - u32 dev_devwidth;
  82. - u32 dev_physaddr; /* If FIFO */
  83. - u32 dev_intlevel;
  84. - u32 dev_intpolarity;
  85. -} dbdev_tab_t;
  86. -
  87. -typedef struct dbdma_chan_config {
  88. - u32 chan_flags;
  89. - u32 chan_index;
  90. - dbdev_tab_t *chan_src;
  91. - dbdev_tab_t *chan_dest;
  92. - au1x_dma_chan_t *chan_ptr;
  93. - au1x_ddma_desc_t *chan_desc_base;
  94. - au1x_ddma_desc_t *get_ptr, *put_ptr, *cur_ptr;
  95. - void *chan_callparam;
  96. - void (*chan_callback)(int, void *, struct pt_regs *);
  97. -} chan_tab_t;
  98. -
  99. -#define DEV_FLAGS_INUSE (1 << 0)
  100. -#define DEV_FLAGS_ANYUSE (1 << 1)
  101. -#define DEV_FLAGS_OUT (1 << 2)
  102. -#define DEV_FLAGS_IN (1 << 3)
  103. -
  104. static dbdev_tab_t dbdev_tab[] = {
  105. #ifdef CONFIG_SOC_AU1550
  106. /* UARTS */
  107. @@ -156,13 +131,13 @@ static dbdev_tab_t dbdev_tab[] = {
  108. { DSCR_CMD0_MAE_BOTH, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },
  109. { DSCR_CMD0_LCD, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },
  110. - { DSCR_CMD0_SDMS_TX0, DEV_FLAGS_OUT, 0, 0, 0x00000000, 0, 0 },
  111. - { DSCR_CMD0_SDMS_RX0, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 },
  112. - { DSCR_CMD0_SDMS_TX1, DEV_FLAGS_OUT, 0, 0, 0x00000000, 0, 0 },
  113. - { DSCR_CMD0_SDMS_RX1, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 },
  114. + { DSCR_CMD0_SDMS_TX0, DEV_FLAGS_OUT, 4, 8, 0x10600000, 0, 0 },
  115. + { DSCR_CMD0_SDMS_RX0, DEV_FLAGS_IN, 4, 8, 0x10600004, 0, 0 },
  116. + { DSCR_CMD0_SDMS_TX1, DEV_FLAGS_OUT, 4, 8, 0x10680000, 0, 0 },
  117. + { DSCR_CMD0_SDMS_RX1, DEV_FLAGS_IN, 4, 8, 0x10680004, 0, 0 },
  118. - { DSCR_CMD0_AES_TX, DEV_FLAGS_OUT, 0, 0, 0x00000000, 0, 0 },
  119. - { DSCR_CMD0_AES_RX, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 },
  120. + { DSCR_CMD0_AES_RX, DEV_FLAGS_IN , 4, 32, 0x10300008, 0, 0 },
  121. + { DSCR_CMD0_AES_TX, DEV_FLAGS_OUT, 4, 32, 0x10300004, 0, 0 },
  122. { DSCR_CMD0_PSC0_TX, DEV_FLAGS_OUT, 0, 0, 0x11a0001c, 0, 0 },
  123. { DSCR_CMD0_PSC0_RX, DEV_FLAGS_IN, 0, 0, 0x11a0001c, 0, 0 },
  124. @@ -172,9 +147,9 @@ static dbdev_tab_t dbdev_tab[] = {
  125. { DSCR_CMD0_PSC1_RX, DEV_FLAGS_IN, 0, 0, 0x11b0001c, 0, 0 },
  126. { DSCR_CMD0_PSC1_SYNC, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },
  127. - { DSCR_CMD0_CIM_RXA, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 },
  128. - { DSCR_CMD0_CIM_RXB, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 },
  129. - { DSCR_CMD0_CIM_RXC, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 },
  130. + { DSCR_CMD0_CIM_RXA, DEV_FLAGS_IN, 0, 32, 0x14004020, 0, 0 },
  131. + { DSCR_CMD0_CIM_RXB, DEV_FLAGS_IN, 0, 32, 0x14004040, 0, 0 },
  132. + { DSCR_CMD0_CIM_RXC, DEV_FLAGS_IN, 0, 32, 0x14004060, 0, 0 },
  133. { DSCR_CMD0_CIM_SYNC, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },
  134. { DSCR_CMD0_NAND_FLASH, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 },
  135. @@ -183,6 +158,24 @@ static dbdev_tab_t dbdev_tab[] = {
  136. { DSCR_CMD0_THROTTLE, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },
  137. { DSCR_CMD0_ALWAYS, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },
  138. +
  139. + /* Provide 16 user definable device types */
  140. + { 0, 0, 0, 0, 0, 0, 0 },
  141. + { 0, 0, 0, 0, 0, 0, 0 },
  142. + { 0, 0, 0, 0, 0, 0, 0 },
  143. + { 0, 0, 0, 0, 0, 0, 0 },
  144. + { 0, 0, 0, 0, 0, 0, 0 },
  145. + { 0, 0, 0, 0, 0, 0, 0 },
  146. + { 0, 0, 0, 0, 0, 0, 0 },
  147. + { 0, 0, 0, 0, 0, 0, 0 },
  148. + { 0, 0, 0, 0, 0, 0, 0 },
  149. + { 0, 0, 0, 0, 0, 0, 0 },
  150. + { 0, 0, 0, 0, 0, 0, 0 },
  151. + { 0, 0, 0, 0, 0, 0, 0 },
  152. + { 0, 0, 0, 0, 0, 0, 0 },
  153. + { 0, 0, 0, 0, 0, 0, 0 },
  154. + { 0, 0, 0, 0, 0, 0, 0 },
  155. + { 0, 0, 0, 0, 0, 0, 0 },
  156. };
  157. #define DBDEV_TAB_SIZE (sizeof(dbdev_tab) / sizeof(dbdev_tab_t))
  158. @@ -202,6 +195,30 @@ find_dbdev_id (u32 id)
  159. return NULL;
  160. }
  161. +u32
  162. +au1xxx_ddma_add_device(dbdev_tab_t *dev)
  163. +{
  164. + u32 ret = 0;
  165. + dbdev_tab_t *p=NULL;
  166. + static u16 new_id=0x1000;
  167. +
  168. + p = find_dbdev_id(0);
  169. + if ( NULL != p )
  170. + {
  171. + memcpy(p, dev, sizeof(dbdev_tab_t));
  172. + p->dev_id = DSCR_DEV2CUSTOM_ID(new_id,dev->dev_id);
  173. + ret = p->dev_id;
  174. + new_id++;
  175. +#if 0
  176. + printk("add_device: id:%x flags:%x padd:%x\n",
  177. + p->dev_id, p->dev_flags, p->dev_physaddr );
  178. +#endif
  179. + }
  180. +
  181. + return ret;
  182. +}
  183. +EXPORT_SYMBOL(au1xxx_ddma_add_device);
  184. +
  185. /* Allocate a channel and return a non-zero descriptor if successful.
  186. */
  187. u32
  188. @@ -214,7 +231,7 @@ au1xxx_dbdma_chan_alloc(u32 srcid, u32 d
  189. int i;
  190. dbdev_tab_t *stp, *dtp;
  191. chan_tab_t *ctp;
  192. - volatile au1x_dma_chan_t *cp;
  193. + au1x_dma_chan_t *cp;
  194. /* We do the intialization on the first channel allocation.
  195. * We have to wait because of the interrupt handler initialization
  196. @@ -224,9 +241,6 @@ au1xxx_dbdma_chan_alloc(u32 srcid, u32 d
  197. au1xxx_dbdma_init();
  198. dbdma_initialized = 1;
  199. - if ((srcid > DSCR_NDEV_IDS) || (destid > DSCR_NDEV_IDS))
  200. - return 0;
  201. -
  202. if ((stp = find_dbdev_id(srcid)) == NULL) return 0;
  203. if ((dtp = find_dbdev_id(destid)) == NULL) return 0;
  204. @@ -268,9 +282,9 @@ au1xxx_dbdma_chan_alloc(u32 srcid, u32 d
  205. /* If kmalloc fails, it is caught below same
  206. * as a channel not available.
  207. */
  208. - ctp = (chan_tab_t *)kmalloc(sizeof(chan_tab_t), GFP_KERNEL);
  209. + ctp = (chan_tab_t *)
  210. + kmalloc(sizeof(chan_tab_t), GFP_KERNEL);
  211. chan_tab_ptr[i] = ctp;
  212. - ctp->chan_index = chan = i;
  213. break;
  214. }
  215. }
  216. @@ -278,10 +292,11 @@ au1xxx_dbdma_chan_alloc(u32 srcid, u32 d
  217. if (ctp != NULL) {
  218. memset(ctp, 0, sizeof(chan_tab_t));
  219. + ctp->chan_index = chan = i;
  220. dcp = DDMA_CHANNEL_BASE;
  221. dcp += (0x0100 * chan);
  222. ctp->chan_ptr = (au1x_dma_chan_t *)dcp;
  223. - cp = (volatile au1x_dma_chan_t *)dcp;
  224. + cp = (au1x_dma_chan_t *)dcp;
  225. ctp->chan_src = stp;
  226. ctp->chan_dest = dtp;
  227. ctp->chan_callback = callback;
  228. @@ -298,6 +313,9 @@ au1xxx_dbdma_chan_alloc(u32 srcid, u32 d
  229. i |= DDMA_CFG_DED;
  230. if (dtp->dev_intpolarity)
  231. i |= DDMA_CFG_DP;
  232. + if ((stp->dev_flags & DEV_FLAGS_SYNC) ||
  233. + (dtp->dev_flags & DEV_FLAGS_SYNC))
  234. + i |= DDMA_CFG_SYNC;
  235. cp->ddma_cfg = i;
  236. au_sync();
  237. @@ -308,14 +326,14 @@ au1xxx_dbdma_chan_alloc(u32 srcid, u32 d
  238. rv = (u32)(&chan_tab_ptr[chan]);
  239. }
  240. else {
  241. - /* Release devices.
  242. - */
  243. + /* Release devices */
  244. stp->dev_flags &= ~DEV_FLAGS_INUSE;
  245. dtp->dev_flags &= ~DEV_FLAGS_INUSE;
  246. }
  247. }
  248. return rv;
  249. }
  250. +EXPORT_SYMBOL(au1xxx_dbdma_chan_alloc);
  251. /* Set the device width if source or destination is a FIFO.
  252. * Should be 8, 16, or 32 bits.
  253. @@ -343,6 +361,7 @@ au1xxx_dbdma_set_devwidth(u32 chanid, in
  254. return rv;
  255. }
  256. +EXPORT_SYMBOL(au1xxx_dbdma_set_devwidth);
  257. /* Allocate a descriptor ring, initializing as much as possible.
  258. */
  259. @@ -369,7 +388,8 @@ au1xxx_dbdma_ring_alloc(u32 chanid, int
  260. * and if we try that first we are likely to not waste larger
  261. * slabs of memory.
  262. */
  263. - desc_base = (u32)kmalloc(entries * sizeof(au1x_ddma_desc_t), GFP_KERNEL);
  264. + desc_base = (u32)kmalloc(entries * sizeof(au1x_ddma_desc_t),
  265. + GFP_KERNEL|GFP_DMA);
  266. if (desc_base == 0)
  267. return 0;
  268. @@ -380,7 +400,7 @@ au1xxx_dbdma_ring_alloc(u32 chanid, int
  269. kfree((const void *)desc_base);
  270. i = entries * sizeof(au1x_ddma_desc_t);
  271. i += (sizeof(au1x_ddma_desc_t) - 1);
  272. - if ((desc_base = (u32)kmalloc(i, GFP_KERNEL)) == 0)
  273. + if ((desc_base = (u32)kmalloc(i, GFP_KERNEL|GFP_DMA)) == 0)
  274. return 0;
  275. desc_base = ALIGN_ADDR(desc_base, sizeof(au1x_ddma_desc_t));
  276. @@ -460,9 +480,14 @@ au1xxx_dbdma_ring_alloc(u32 chanid, int
  277. /* If source input is fifo, set static address.
  278. */
  279. if (stp->dev_flags & DEV_FLAGS_IN) {
  280. - src0 = stp->dev_physaddr;
  281. - src1 |= DSCR_SRC1_SAM(DSCR_xAM_STATIC);
  282. + if ( stp->dev_flags & DEV_FLAGS_BURSTABLE )
  283. + src1 |= DSCR_SRC1_SAM(DSCR_xAM_BURST);
  284. + else
  285. + src1 |= DSCR_SRC1_SAM(DSCR_xAM_STATIC);
  286. +
  287. }
  288. + if (stp->dev_physaddr)
  289. + src0 = stp->dev_physaddr;
  290. /* Set up dest1. For now, assume no stride and increment.
  291. * A channel attribute update can change this later.
  292. @@ -486,10 +511,18 @@ au1xxx_dbdma_ring_alloc(u32 chanid, int
  293. /* If destination output is fifo, set static address.
  294. */
  295. if (dtp->dev_flags & DEV_FLAGS_OUT) {
  296. - dest0 = dtp->dev_physaddr;
  297. + if ( dtp->dev_flags & DEV_FLAGS_BURSTABLE )
  298. + dest1 |= DSCR_DEST1_DAM(DSCR_xAM_BURST);
  299. + else
  300. dest1 |= DSCR_DEST1_DAM(DSCR_xAM_STATIC);
  301. }
  302. + if (dtp->dev_physaddr)
  303. + dest0 = dtp->dev_physaddr;
  304. +#if 0
  305. + printk("did:%x sid:%x cmd0:%x cmd1:%x source0:%x source1:%x dest0:%x dest1:%x\n",
  306. + dtp->dev_id, stp->dev_id, cmd0, cmd1, src0, src1, dest0, dest1 );
  307. +#endif
  308. for (i=0; i<entries; i++) {
  309. dp->dscr_cmd0 = cmd0;
  310. dp->dscr_cmd1 = cmd1;
  311. @@ -498,6 +531,7 @@ au1xxx_dbdma_ring_alloc(u32 chanid, int
  312. dp->dscr_dest0 = dest0;
  313. dp->dscr_dest1 = dest1;
  314. dp->dscr_stat = 0;
  315. + dp->sw_context = dp->sw_status = 0;
  316. dp->dscr_nxtptr = DSCR_NXTPTR(virt_to_phys(dp + 1));
  317. dp++;
  318. }
  319. @@ -510,13 +544,14 @@ au1xxx_dbdma_ring_alloc(u32 chanid, int
  320. return (u32)(ctp->chan_desc_base);
  321. }
  322. +EXPORT_SYMBOL(au1xxx_dbdma_ring_alloc);
  323. /* Put a source buffer into the DMA ring.
  324. * This updates the source pointer and byte count. Normally used
  325. * for memory to fifo transfers.
  326. */
  327. u32
  328. -au1xxx_dbdma_put_source(u32 chanid, void *buf, int nbytes)
  329. +_au1xxx_dbdma_put_source(u32 chanid, void *buf, int nbytes, u32 flags)
  330. {
  331. chan_tab_t *ctp;
  332. au1x_ddma_desc_t *dp;
  333. @@ -543,24 +578,40 @@ au1xxx_dbdma_put_source(u32 chanid, void
  334. */
  335. dp->dscr_source0 = virt_to_phys(buf);
  336. dp->dscr_cmd1 = nbytes;
  337. - dp->dscr_cmd0 |= DSCR_CMD0_V; /* Let it rip */
  338. - ctp->chan_ptr->ddma_dbell = 0xffffffff; /* Make it go */
  339. -
  340. + /* Check flags */
  341. + if (flags & DDMA_FLAGS_IE)
  342. + dp->dscr_cmd0 |= DSCR_CMD0_IE;
  343. + if (flags & DDMA_FLAGS_NOIE)
  344. + dp->dscr_cmd0 &= ~DSCR_CMD0_IE;
  345. /* Get next descriptor pointer.
  346. */
  347. ctp->put_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr));
  348. + /*
  349. + * There is an errata on the Au1200/Au1550 parts that could result
  350. + * in "stale" data being DMA'd. It has to do with the snoop logic on
  351. + * the dache eviction buffer. NONCOHERENT_IO is on by default for
  352. + * these parts. If it is fixedin the future, these dma_cache_inv will
  353. + * just be nothing more than empty macros. See io.h.
  354. + * */
  355. + dma_cache_wback_inv(buf,nbytes);
  356. + dp->dscr_cmd0 |= DSCR_CMD0_V; /* Let it rip */
  357. + au_sync();
  358. + dma_cache_wback_inv(dp, sizeof(dp));
  359. + ctp->chan_ptr->ddma_dbell = 0;
  360. +
  361. /* return something not zero.
  362. */
  363. return nbytes;
  364. }
  365. +EXPORT_SYMBOL(_au1xxx_dbdma_put_source);
  366. /* Put a destination buffer into the DMA ring.
  367. * This updates the destination pointer and byte count. Normally used
  368. * to place an empty buffer into the ring for fifo to memory transfers.
  369. */
  370. u32
  371. -au1xxx_dbdma_put_dest(u32 chanid, void *buf, int nbytes)
  372. +_au1xxx_dbdma_put_dest(u32 chanid, void *buf, int nbytes, u32 flags)
  373. {
  374. chan_tab_t *ctp;
  375. au1x_ddma_desc_t *dp;
  376. @@ -582,11 +633,33 @@ au1xxx_dbdma_put_dest(u32 chanid, void *
  377. if (dp->dscr_cmd0 & DSCR_CMD0_V)
  378. return 0;
  379. - /* Load up buffer address and byte count.
  380. - */
  381. + /* Load up buffer address and byte count */
  382. +
  383. + /* Check flags */
  384. + if (flags & DDMA_FLAGS_IE)
  385. + dp->dscr_cmd0 |= DSCR_CMD0_IE;
  386. + if (flags & DDMA_FLAGS_NOIE)
  387. + dp->dscr_cmd0 &= ~DSCR_CMD0_IE;
  388. +
  389. dp->dscr_dest0 = virt_to_phys(buf);
  390. dp->dscr_cmd1 = nbytes;
  391. +#if 0
  392. + printk("cmd0:%x cmd1:%x source0:%x source1:%x dest0:%x dest1:%x\n",
  393. + dp->dscr_cmd0, dp->dscr_cmd1, dp->dscr_source0,
  394. + dp->dscr_source1, dp->dscr_dest0, dp->dscr_dest1 );
  395. +#endif
  396. + /*
  397. + * There is an errata on the Au1200/Au1550 parts that could result in
  398. + * "stale" data being DMA'd. It has to do with the snoop logic on the
  399. + * dache eviction buffer. NONCOHERENT_IO is on by default for these
  400. + * parts. If it is fixedin the future, these dma_cache_inv will just
  401. + * be nothing more than empty macros. See io.h.
  402. + * */
  403. + dma_cache_inv(buf,nbytes);
  404. dp->dscr_cmd0 |= DSCR_CMD0_V; /* Let it rip */
  405. + au_sync();
  406. + dma_cache_wback_inv(dp, sizeof(dp));
  407. + ctp->chan_ptr->ddma_dbell = 0;
  408. /* Get next descriptor pointer.
  409. */
  410. @@ -596,6 +669,7 @@ au1xxx_dbdma_put_dest(u32 chanid, void *
  411. */
  412. return nbytes;
  413. }
  414. +EXPORT_SYMBOL(_au1xxx_dbdma_put_dest);
  415. /* Get a destination buffer into the DMA ring.
  416. * Normally used to get a full buffer from the ring during fifo
  417. @@ -645,7 +719,7 @@ void
  418. au1xxx_dbdma_stop(u32 chanid)
  419. {
  420. chan_tab_t *ctp;
  421. - volatile au1x_dma_chan_t *cp;
  422. + au1x_dma_chan_t *cp;
  423. int halt_timeout = 0;
  424. ctp = *((chan_tab_t **)chanid);
  425. @@ -665,6 +739,7 @@ au1xxx_dbdma_stop(u32 chanid)
  426. cp->ddma_stat |= (DDMA_STAT_DB | DDMA_STAT_V);
  427. au_sync();
  428. }
  429. +EXPORT_SYMBOL(au1xxx_dbdma_stop);
  430. /* Start using the current descriptor pointer. If the dbdma encounters
  431. * a not valid descriptor, it will stop. In this case, we can just
  432. @@ -674,17 +749,17 @@ void
  433. au1xxx_dbdma_start(u32 chanid)
  434. {
  435. chan_tab_t *ctp;
  436. - volatile au1x_dma_chan_t *cp;
  437. + au1x_dma_chan_t *cp;
  438. ctp = *((chan_tab_t **)chanid);
  439. -
  440. cp = ctp->chan_ptr;
  441. cp->ddma_desptr = virt_to_phys(ctp->cur_ptr);
  442. cp->ddma_cfg |= DDMA_CFG_EN; /* Enable channel */
  443. au_sync();
  444. - cp->ddma_dbell = 0xffffffff; /* Make it go */
  445. + cp->ddma_dbell = 0;
  446. au_sync();
  447. }
  448. +EXPORT_SYMBOL(au1xxx_dbdma_start);
  449. void
  450. au1xxx_dbdma_reset(u32 chanid)
  451. @@ -703,15 +778,21 @@ au1xxx_dbdma_reset(u32 chanid)
  452. do {
  453. dp->dscr_cmd0 &= ~DSCR_CMD0_V;
  454. + /* reset our SW status -- this is used to determine
  455. + * if a descriptor is in use by upper level SW. Since
  456. + * posting can reset 'V' bit.
  457. + */
  458. + dp->sw_status = 0;
  459. dp = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr));
  460. } while (dp != ctp->chan_desc_base);
  461. }
  462. +EXPORT_SYMBOL(au1xxx_dbdma_reset);
  463. u32
  464. au1xxx_get_dma_residue(u32 chanid)
  465. {
  466. chan_tab_t *ctp;
  467. - volatile au1x_dma_chan_t *cp;
  468. + au1x_dma_chan_t *cp;
  469. u32 rv;
  470. ctp = *((chan_tab_t **)chanid);
  471. @@ -746,15 +827,16 @@ au1xxx_dbdma_chan_free(u32 chanid)
  472. kfree(ctp);
  473. }
  474. +EXPORT_SYMBOL(au1xxx_dbdma_chan_free);
  475. static void
  476. dbdma_interrupt(int irq, void *dev_id, struct pt_regs *regs)
  477. {
  478. - u32 intstat;
  479. + u32 intstat, flags;
  480. u32 chan_index;
  481. chan_tab_t *ctp;
  482. au1x_ddma_desc_t *dp;
  483. - volatile au1x_dma_chan_t *cp;
  484. + au1x_dma_chan_t *cp;
  485. intstat = dbdma_gptr->ddma_intstat;
  486. au_sync();
  487. @@ -773,18 +855,26 @@ dbdma_interrupt(int irq, void *dev_id, s
  488. (ctp->chan_callback)(irq, ctp->chan_callparam, regs);
  489. ctp->cur_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr));
  490. -
  491. }
  492. -static void
  493. -au1xxx_dbdma_init(void)
  494. +static void au1xxx_dbdma_init(void)
  495. {
  496. + int irq_nr;
  497. +
  498. dbdma_gptr->ddma_config = 0;
  499. dbdma_gptr->ddma_throttle = 0;
  500. dbdma_gptr->ddma_inten = 0xffff;
  501. au_sync();
  502. - if (request_irq(AU1550_DDMA_INT, dbdma_interrupt, SA_INTERRUPT,
  503. +#if defined(CONFIG_SOC_AU1550)
  504. + irq_nr = AU1550_DDMA_INT;
  505. +#elif defined(CONFIG_SOC_AU1200)
  506. + irq_nr = AU1200_DDMA_INT;
  507. +#else
  508. + #error Unknown Au1x00 SOC
  509. +#endif
  510. +
  511. + if (request_irq(irq_nr, dbdma_interrupt, SA_INTERRUPT,
  512. "Au1xxx dbdma", (void *)dbdma_gptr))
  513. printk("Can't get 1550 dbdma irq");
  514. }
  515. @@ -795,7 +885,8 @@ au1xxx_dbdma_dump(u32 chanid)
  516. chan_tab_t *ctp;
  517. au1x_ddma_desc_t *dp;
  518. dbdev_tab_t *stp, *dtp;
  519. - volatile au1x_dma_chan_t *cp;
  520. + au1x_dma_chan_t *cp;
  521. + u32 i = 0;
  522. ctp = *((chan_tab_t **)chanid);
  523. stp = ctp->chan_src;
  524. @@ -820,15 +911,64 @@ au1xxx_dbdma_dump(u32 chanid)
  525. dp = ctp->chan_desc_base;
  526. do {
  527. - printk("dp %08x, cmd0 %08x, cmd1 %08x\n",
  528. - (u32)dp, dp->dscr_cmd0, dp->dscr_cmd1);
  529. - printk("src0 %08x, src1 %08x, dest0 %08x\n",
  530. - dp->dscr_source0, dp->dscr_source1, dp->dscr_dest0);
  531. - printk("dest1 %08x, stat %08x, nxtptr %08x\n",
  532. - dp->dscr_dest1, dp->dscr_stat, dp->dscr_nxtptr);
  533. + printk("Dp[%d]= %08x, cmd0 %08x, cmd1 %08x\n",
  534. + i++, (u32)dp, dp->dscr_cmd0, dp->dscr_cmd1);
  535. + printk("src0 %08x, src1 %08x, dest0 %08x, dest1 %08x\n",
  536. + dp->dscr_source0, dp->dscr_source1, dp->dscr_dest0, dp->dscr_dest1);
  537. + printk("stat %08x, nxtptr %08x\n",
  538. + dp->dscr_stat, dp->dscr_nxtptr);
  539. dp = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr));
  540. } while (dp != ctp->chan_desc_base);
  541. }
  542. +/* Put a descriptor into the DMA ring.
  543. + * This updates the source/destination pointers and byte count.
  544. + */
  545. +u32
  546. +au1xxx_dbdma_put_dscr(u32 chanid, au1x_ddma_desc_t *dscr )
  547. +{
  548. + chan_tab_t *ctp;
  549. + au1x_ddma_desc_t *dp;
  550. + u32 nbytes=0;
  551. +
  552. + /* I guess we could check this to be within the
  553. + * range of the table......
  554. + */
  555. + ctp = *((chan_tab_t **)chanid);
  556. +
  557. + /* We should have multiple callers for a particular channel,
  558. + * an interrupt doesn't affect this pointer nor the descriptor,
  559. + * so no locking should be needed.
  560. + */
  561. + dp = ctp->put_ptr;
  562. +
  563. + /* If the descriptor is valid, we are way ahead of the DMA
  564. + * engine, so just return an error condition.
  565. + */
  566. + if (dp->dscr_cmd0 & DSCR_CMD0_V)
  567. + return 0;
  568. +
  569. + /* Load up buffer addresses and byte count.
  570. + */
  571. + dp->dscr_dest0 = dscr->dscr_dest0;
  572. + dp->dscr_source0 = dscr->dscr_source0;
  573. + dp->dscr_dest1 = dscr->dscr_dest1;
  574. + dp->dscr_source1 = dscr->dscr_source1;
  575. + dp->dscr_cmd1 = dscr->dscr_cmd1;
  576. + nbytes = dscr->dscr_cmd1;
  577. + /* Allow the caller to specifiy if an interrupt is generated */
  578. + dp->dscr_cmd0 &= ~DSCR_CMD0_IE;
  579. + dp->dscr_cmd0 |= dscr->dscr_cmd0 | DSCR_CMD0_V;
  580. + ctp->chan_ptr->ddma_dbell = 0;
  581. +
  582. + /* Get next descriptor pointer.
  583. + */
  584. + ctp->put_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr));
  585. +
  586. + /* return something not zero.
  587. + */
  588. + return nbytes;
  589. +}
  590. +
  591. #endif /* defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200) */
  592. --- /dev/null
  593. +++ b/arch/mips/au1000/common/gpio.c
  594. @@ -0,0 +1,118 @@
  595. +/*
  596. + * This program is free software; you can redistribute it and/or modify it
  597. + * under the terms of the GNU General Public License as published by the
  598. + * Free Software Foundation; either version 2 of the License, or (at your
  599. + * option) any later version.
  600. + *
  601. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  602. + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  603. + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  604. + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  605. + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  606. + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  607. + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  608. + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  609. + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  610. + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  611. + *
  612. + * You should have received a copy of the GNU General Public License along
  613. + * with this program; if not, write to the Free Software Foundation, Inc.,
  614. + * 675 Mass Ave, Cambridge, MA 02139, USA.
  615. + */
  616. +
  617. +#include <asm/au1000.h>
  618. +#include <asm/au1xxx_gpio.h>
  619. +
  620. +#define gpio1 sys
  621. +#if !defined(CONFIG_SOC_AU1000)
  622. +static AU1X00_GPIO2 * const gpio2 = (AU1X00_GPIO2 *)GPIO2_BASE;
  623. +
  624. +#define GPIO2_OUTPUT_ENABLE_MASK 0x00010000
  625. +
  626. +int au1xxx_gpio2_read(int signal)
  627. +{
  628. + signal -= 200;
  629. +/* gpio2->dir &= ~(0x01 << signal); //Set GPIO to input */
  630. + return ((gpio2->pinstate >> signal) & 0x01);
  631. +}
  632. +
  633. +void au1xxx_gpio2_write(int signal, int value)
  634. +{
  635. + signal -= 200;
  636. +
  637. + gpio2->output = (GPIO2_OUTPUT_ENABLE_MASK << signal) |
  638. + (value << signal);
  639. +}
  640. +
  641. +void au1xxx_gpio2_tristate(int signal)
  642. +{
  643. + signal -= 200;
  644. + gpio2->dir &= ~(0x01 << signal); /* Set GPIO to input */
  645. +}
  646. +#endif
  647. +
  648. +int au1xxx_gpio1_read(int signal)
  649. +{
  650. +/* gpio1->trioutclr |= (0x01 << signal); */
  651. + return ((gpio1->pinstaterd >> signal) & 0x01);
  652. +}
  653. +
  654. +void au1xxx_gpio1_write(int signal, int value)
  655. +{
  656. + if(value)
  657. + gpio1->outputset = (0x01 << signal);
  658. + else
  659. + gpio1->outputclr = (0x01 << signal); /* Output a Zero */
  660. +}
  661. +
  662. +void au1xxx_gpio1_tristate(int signal)
  663. +{
  664. + gpio1->trioutclr = (0x01 << signal); /* Tristate signal */
  665. +}
  666. +
  667. +
  668. +int au1xxx_gpio_read(int signal)
  669. +{
  670. + if(signal >= 200)
  671. +#if defined(CONFIG_SOC_AU1000)
  672. + return 0;
  673. +#else
  674. + return au1xxx_gpio2_read(signal);
  675. +#endif
  676. + else
  677. + return au1xxx_gpio1_read(signal);
  678. +}
  679. +
  680. +void au1xxx_gpio_write(int signal, int value)
  681. +{
  682. + if(signal >= 200)
  683. +#if defined(CONFIG_SOC_AU1000)
  684. + ;
  685. +#else
  686. + au1xxx_gpio2_write(signal, value);
  687. +#endif
  688. + else
  689. + au1xxx_gpio1_write(signal, value);
  690. +}
  691. +
  692. +void au1xxx_gpio_tristate(int signal)
  693. +{
  694. + if(signal >= 200)
  695. +#if defined(CONFIG_SOC_AU1000)
  696. + ;
  697. +#else
  698. + au1xxx_gpio2_tristate(signal);
  699. +#endif
  700. + else
  701. + au1xxx_gpio1_tristate(signal);
  702. +}
  703. +
  704. +void au1xxx_gpio1_set_inputs(void)
  705. +{
  706. + gpio1->pininputen = 0;
  707. +}
  708. +
  709. +EXPORT_SYMBOL(au1xxx_gpio1_set_inputs);
  710. +EXPORT_SYMBOL(au1xxx_gpio_tristate);
  711. +EXPORT_SYMBOL(au1xxx_gpio_write);
  712. +EXPORT_SYMBOL(au1xxx_gpio_read);
  713. --- a/arch/mips/au1000/common/irq.c
  714. +++ b/arch/mips/au1000/common/irq.c
  715. @@ -303,8 +303,30 @@ static struct hw_interrupt_type level_ir
  716. };
  717. #ifdef CONFIG_PM
  718. -void startup_match20_interrupt(void)
  719. +void startup_match20_interrupt(void (*handler)(int, void *, struct pt_regs *))
  720. {
  721. + static struct irqaction action;
  722. + /* This is a big problem.... since we didn't use request_irq
  723. + when kernel/irq.c calls probe_irq_xxx this interrupt will
  724. + be probed for usage. This will end up disabling the device :(
  725. +
  726. + Give it a bogus "action" pointer -- this will keep it from
  727. + getting auto-probed!
  728. +
  729. + By setting the status to match that of request_irq() we
  730. + can avoid it. --cgray
  731. + */
  732. + action.dev_id = handler;
  733. + action.flags = 0;
  734. + action.mask = 0;
  735. + action.name = "Au1xxx TOY";
  736. + action.handler = handler;
  737. + action.next = NULL;
  738. +
  739. + irq_desc[AU1000_TOY_MATCH2_INT].action = &action;
  740. + irq_desc[AU1000_TOY_MATCH2_INT].status
  741. + &= ~(IRQ_DISABLED | IRQ_AUTODETECT | IRQ_WAITING | IRQ_INPROGRESS);
  742. +
  743. local_enable_irq(AU1000_TOY_MATCH2_INT);
  744. }
  745. #endif
  746. @@ -508,6 +530,7 @@ void intc0_req0_irqdispatch(struct pt_re
  747. if (!intc0_req0) return;
  748. +#ifdef AU1000_USB_DEV_REQ_INT
  749. /*
  750. * Because of the tight timing of SETUP token to reply
  751. * transactions, the USB devices-side packet complete
  752. @@ -518,6 +541,7 @@ void intc0_req0_irqdispatch(struct pt_re
  753. do_IRQ(AU1000_USB_DEV_REQ_INT, regs);
  754. return;
  755. }
  756. +#endif
  757. irq = au_ffs(intc0_req0) - 1;
  758. intc0_req0 &= ~(1<<irq);
  759. @@ -536,17 +560,7 @@ void intc0_req1_irqdispatch(struct pt_re
  760. irq = au_ffs(intc0_req1) - 1;
  761. intc0_req1 &= ~(1<<irq);
  762. -#ifdef CONFIG_PM
  763. - if (irq == AU1000_TOY_MATCH2_INT) {
  764. - mask_and_ack_rise_edge_irq(irq);
  765. - counter0_irq(irq, NULL, regs);
  766. - local_enable_irq(irq);
  767. - }
  768. - else
  769. -#endif
  770. - {
  771. - do_IRQ(irq, regs);
  772. - }
  773. + do_IRQ(irq, regs);
  774. }
  775. --- a/arch/mips/au1000/common/Makefile
  776. +++ b/arch/mips/au1000/common/Makefile
  777. @@ -19,9 +19,9 @@ O_TARGET := au1000.o
  778. export-objs = prom.o clocks.o power.o usbdev.o
  779. obj-y := prom.o int-handler.o irq.o puts.o time.o reset.o cputable.o \
  780. - au1xxx_irqmap.o clocks.o power.o setup.o sleeper.o dma.o dbdma.o
  781. + au1xxx_irqmap.o clocks.o power.o setup.o sleeper.o dma.o dbdma.o gpio.o
  782. -export-objs += dma.o dbdma.o
  783. +export-objs += dma.o dbdma.o gpio.o
  784. obj-$(CONFIG_AU1X00_USB_DEVICE) += usbdev.o
  785. obj-$(CONFIG_KGDB) += dbg_io.o
  786. --- a/arch/mips/au1000/common/pci_fixup.c
  787. +++ b/arch/mips/au1000/common/pci_fixup.c
  788. @@ -75,9 +75,13 @@ void __init pcibios_fixup(void)
  789. #ifdef CONFIG_NONCOHERENT_IO
  790. /*
  791. - * Set the NC bit in controller for pre-AC silicon
  792. + * Set the NC bit in controller for Au1500 pre-AC silicon
  793. */
  794. - au_writel( 1<<16 | au_readl(Au1500_PCI_CFG), Au1500_PCI_CFG);
  795. + u32 prid = read_c0_prid();
  796. + if ( (prid & 0xFF000000) == 0x01000000 && prid < 0x01030202) {
  797. + au_writel( 1<<16 | au_readl(Au1500_PCI_CFG), Au1500_PCI_CFG);
  798. + printk("Non-coherent PCI accesses enabled\n");
  799. + }
  800. printk("Non-coherent PCI accesses enabled\n");
  801. #endif
  802. --- a/arch/mips/au1000/common/pci_ops.c
  803. +++ b/arch/mips/au1000/common/pci_ops.c
  804. @@ -162,6 +162,7 @@ unsigned long last_entryLo0, last_entryL
  805. static int config_access(unsigned char access_type, struct pci_dev *dev,
  806. unsigned char where, u32 * data)
  807. {
  808. + int error = PCIBIOS_SUCCESSFUL;
  809. #if defined( CONFIG_SOC_AU1500 ) || defined( CONFIG_SOC_AU1550 )
  810. unsigned char bus = dev->bus->number;
  811. unsigned int dev_fn = dev->devfn;
  812. @@ -170,7 +171,6 @@ static int config_access(unsigned char a
  813. unsigned long offset, status;
  814. unsigned long cfg_base;
  815. unsigned long flags;
  816. - int error = PCIBIOS_SUCCESSFUL;
  817. unsigned long entryLo0, entryLo1;
  818. if (device > 19) {
  819. @@ -205,9 +205,8 @@ static int config_access(unsigned char a
  820. last_entryLo0 = last_entryLo1 = 0xffffffff;
  821. }
  822. - /* Since the Au1xxx doesn't do the idsel timing exactly to spec,
  823. - * many board vendors implement their own off-chip idsel, so call
  824. - * it now. If it doesn't succeed, may as well bail out at this point.
  825. + /* Allow board vendors to implement their own off-chip idsel.
  826. + * If it doesn't succeed, may as well bail out at this point.
  827. */
  828. if (board_pci_idsel) {
  829. if (board_pci_idsel(device, 1) == 0) {
  830. @@ -271,8 +270,11 @@ static int config_access(unsigned char a
  831. }
  832. local_irq_restore(flags);
  833. - return error;
  834. +#else
  835. + /* Fake out Config space access with no responder */
  836. + *data = 0xFFFFFFFF;
  837. #endif
  838. + return error;
  839. }
  840. #endif
  841. --- a/arch/mips/au1000/common/power.c
  842. +++ b/arch/mips/au1000/common/power.c
  843. @@ -50,7 +50,6 @@
  844. static void calibrate_delay(void);
  845. -extern void set_au1x00_speed(unsigned int new_freq);
  846. extern unsigned int get_au1x00_speed(void);
  847. extern unsigned long get_au1x00_uart_baud_base(void);
  848. extern void set_au1x00_uart_baud_base(unsigned long new_baud_base);
  849. @@ -116,6 +115,7 @@ save_core_regs(void)
  850. sleep_uart0_clkdiv = au_readl(UART0_ADDR + UART_CLK);
  851. sleep_uart0_enable = au_readl(UART0_ADDR + UART_MOD_CNTRL);
  852. +#ifndef CONFIG_SOC_AU1200
  853. /* Shutdown USB host/device.
  854. */
  855. sleep_usbhost_enable = au_readl(USB_HOST_CONFIG);
  856. @@ -127,6 +127,7 @@ save_core_regs(void)
  857. sleep_usbdev_enable = au_readl(USBD_ENABLE);
  858. au_writel(0, USBD_ENABLE); au_sync();
  859. +#endif
  860. /* Save interrupt controller state.
  861. */
  862. @@ -212,14 +213,12 @@ void wakeup_from_suspend(void)
  863. int au_sleep(void)
  864. {
  865. unsigned long wakeup, flags;
  866. - extern void save_and_sleep(void);
  867. + extern unsigned int save_and_sleep(void);
  868. spin_lock_irqsave(&pm_lock,flags);
  869. save_core_regs();
  870. - flush_cache_all();
  871. -
  872. /** The code below is all system dependent and we should probably
  873. ** have a function call out of here to set this up. You need
  874. ** to configure the GPIO or timer interrupts that will bring
  875. @@ -227,27 +226,26 @@ int au_sleep(void)
  876. ** For testing, the TOY counter wakeup is useful.
  877. **/
  878. -#if 0
  879. +#if 1
  880. au_writel(au_readl(SYS_PINSTATERD) & ~(1 << 11), SYS_PINSTATERD);
  881. /* gpio 6 can cause a wake up event */
  882. wakeup = au_readl(SYS_WAKEMSK);
  883. wakeup &= ~(1 << 8); /* turn off match20 wakeup */
  884. - wakeup |= 1 << 6; /* turn on gpio 6 wakeup */
  885. + wakeup = 1 << 5; /* turn on gpio 6 wakeup */
  886. #else
  887. - /* For testing, allow match20 to wake us up.
  888. - */
  889. + /* For testing, allow match20 to wake us up. */
  890. #ifdef SLEEP_TEST_TIMEOUT
  891. wakeup_counter0_set(sleep_ticks);
  892. #endif
  893. wakeup = 1 << 8; /* turn on match20 wakeup */
  894. wakeup = 0;
  895. #endif
  896. - au_writel(1, SYS_WAKESRC); /* clear cause */
  897. + au_writel(0, SYS_WAKESRC); /* clear cause */
  898. au_sync();
  899. au_writel(wakeup, SYS_WAKEMSK);
  900. au_sync();
  901. -
  902. + DPRINTK("Entering sleep!\n");
  903. save_and_sleep();
  904. /* after a wakeup, the cpu vectors back to 0x1fc00000 so
  905. @@ -255,6 +253,7 @@ int au_sleep(void)
  906. */
  907. restore_core_regs();
  908. spin_unlock_irqrestore(&pm_lock, flags);
  909. + DPRINTK("Leaving sleep!\n");
  910. return 0;
  911. }
  912. @@ -285,7 +284,6 @@ static int pm_do_sleep(ctl_table * ctl,
  913. if (retval)
  914. return retval;
  915. -
  916. au_sleep();
  917. retval = pm_send_all(PM_RESUME, (void *) 0);
  918. }
  919. @@ -296,7 +294,6 @@ static int pm_do_suspend(ctl_table * ctl
  920. void *buffer, size_t * len)
  921. {
  922. int retval = 0;
  923. - void au1k_wait(void);
  924. if (!write) {
  925. *len = 0;
  926. @@ -305,119 +302,9 @@ static int pm_do_suspend(ctl_table * ctl
  927. if (retval)
  928. return retval;
  929. suspend_mode = 1;
  930. - au1k_wait();
  931. - retval = pm_send_all(PM_RESUME, (void *) 0);
  932. - }
  933. - return retval;
  934. -}
  935. -
  936. -static int pm_do_freq(ctl_table * ctl, int write, struct file *file,
  937. - void *buffer, size_t * len)
  938. -{
  939. - int retval = 0, i;
  940. - unsigned long val, pll;
  941. -#define TMPBUFLEN 64
  942. -#define MAX_CPU_FREQ 396
  943. - char buf[TMPBUFLEN], *p;
  944. - unsigned long flags, intc0_mask, intc1_mask;
  945. - unsigned long old_baud_base, old_cpu_freq, baud_rate, old_clk,
  946. - old_refresh;
  947. - unsigned long new_baud_base, new_cpu_freq, new_clk, new_refresh;
  948. -
  949. - spin_lock_irqsave(&pm_lock, flags);
  950. - if (!write) {
  951. - *len = 0;
  952. - } else {
  953. - /* Parse the new frequency */
  954. - if (*len > TMPBUFLEN - 1) {
  955. - spin_unlock_irqrestore(&pm_lock, flags);
  956. - return -EFAULT;
  957. - }
  958. - if (copy_from_user(buf, buffer, *len)) {
  959. - spin_unlock_irqrestore(&pm_lock, flags);
  960. - return -EFAULT;
  961. - }
  962. - buf[*len] = 0;
  963. - p = buf;
  964. - val = simple_strtoul(p, &p, 0);
  965. - if (val > MAX_CPU_FREQ) {
  966. - spin_unlock_irqrestore(&pm_lock, flags);
  967. - return -EFAULT;
  968. - }
  969. -
  970. - pll = val / 12;
  971. - if ((pll > 33) || (pll < 7)) { /* 396 MHz max, 84 MHz min */
  972. - /* revisit this for higher speed cpus */
  973. - spin_unlock_irqrestore(&pm_lock, flags);
  974. - return -EFAULT;
  975. - }
  976. -
  977. - old_baud_base = get_au1x00_uart_baud_base();
  978. - old_cpu_freq = get_au1x00_speed();
  979. -
  980. - new_cpu_freq = pll * 12 * 1000000;
  981. - new_baud_base = (new_cpu_freq / (2 * ((int)(au_readl(SYS_POWERCTRL)&0x03) + 2) * 16));
  982. - set_au1x00_speed(new_cpu_freq);
  983. - set_au1x00_uart_baud_base(new_baud_base);
  984. -
  985. - old_refresh = au_readl(MEM_SDREFCFG) & 0x1ffffff;
  986. - new_refresh =
  987. - ((old_refresh * new_cpu_freq) /
  988. - old_cpu_freq) | (au_readl(MEM_SDREFCFG) & ~0x1ffffff);
  989. -
  990. - au_writel(pll, SYS_CPUPLL);
  991. - au_sync_delay(1);
  992. - au_writel(new_refresh, MEM_SDREFCFG);
  993. - au_sync_delay(1);
  994. -
  995. - for (i = 0; i < 4; i++) {
  996. - if (au_readl
  997. - (UART_BASE + UART_MOD_CNTRL +
  998. - i * 0x00100000) == 3) {
  999. - old_clk =
  1000. - au_readl(UART_BASE + UART_CLK +
  1001. - i * 0x00100000);
  1002. - // baud_rate = baud_base/clk
  1003. - baud_rate = old_baud_base / old_clk;
  1004. - /* we won't get an exact baud rate and the error
  1005. - * could be significant enough that our new
  1006. - * calculation will result in a clock that will
  1007. - * give us a baud rate that's too far off from
  1008. - * what we really want.
  1009. - */
  1010. - if (baud_rate > 100000)
  1011. - baud_rate = 115200;
  1012. - else if (baud_rate > 50000)
  1013. - baud_rate = 57600;
  1014. - else if (baud_rate > 30000)
  1015. - baud_rate = 38400;
  1016. - else if (baud_rate > 17000)
  1017. - baud_rate = 19200;
  1018. - else
  1019. - (baud_rate = 9600);
  1020. - // new_clk = new_baud_base/baud_rate
  1021. - new_clk = new_baud_base / baud_rate;
  1022. - au_writel(new_clk,
  1023. - UART_BASE + UART_CLK +
  1024. - i * 0x00100000);
  1025. - au_sync_delay(10);
  1026. - }
  1027. - }
  1028. + retval = pm_send_all(PM_RESUME, (void *) 0);
  1029. }
  1030. -
  1031. -
  1032. - /* We don't want _any_ interrupts other than
  1033. - * match20. Otherwise our calibrate_delay()
  1034. - * calculation will be off, potentially a lot.
  1035. - */
  1036. - intc0_mask = save_local_and_disable(0);
  1037. - intc1_mask = save_local_and_disable(1);
  1038. - local_enable_irq(AU1000_TOY_MATCH2_INT);
  1039. - spin_unlock_irqrestore(&pm_lock, flags);
  1040. - calibrate_delay();
  1041. - restore_local_and_enable(0, intc0_mask);
  1042. - restore_local_and_enable(1, intc1_mask);
  1043. return retval;
  1044. }
  1045. @@ -425,7 +312,6 @@ static int pm_do_freq(ctl_table * ctl, i
  1046. static struct ctl_table pm_table[] = {
  1047. {ACPI_S1_SLP_TYP, "suspend", NULL, 0, 0600, NULL, &pm_do_suspend},
  1048. {ACPI_SLEEP, "sleep", NULL, 0, 0600, NULL, &pm_do_sleep},
  1049. - {CTL_ACPI, "freq", NULL, 0, 0600, NULL, &pm_do_freq},
  1050. {0}
  1051. };
  1052. --- a/arch/mips/au1000/common/reset.c
  1053. +++ b/arch/mips/au1000/common/reset.c
  1054. @@ -37,8 +37,6 @@
  1055. #include <asm/system.h>
  1056. #include <asm/au1000.h>
  1057. -extern int au_sleep(void);
  1058. -
  1059. void au1000_restart(char *command)
  1060. {
  1061. /* Set all integrated peripherals to disabled states */
  1062. @@ -144,6 +142,26 @@ void au1000_restart(char *command)
  1063. au_writel(0x00, 0xb1900064); /* sys_auxpll */
  1064. au_writel(0x00, 0xb1900100); /* sys_pininputen */
  1065. break;
  1066. + case 0x04000000: /* Au1200 */
  1067. + au_writel(0x00, 0xb400300c); /* ddma */
  1068. + au_writel(0x00, 0xb1a00004); /* psc 0 */
  1069. + au_writel(0x00, 0xb1b00004); /* psc 1 */
  1070. + au_writel(0x00d02000, 0xb4020004); /* ehci, ohci, udc, otg */
  1071. + au_writel(0x00, 0xb5000004); /* lcd */
  1072. + au_writel(0x00, 0xb060000c); /* sd0 */
  1073. + au_writel(0x00, 0xb068000c); /* sd1 */
  1074. + au_writel(0x00, 0xb1100100); /* swcnt */
  1075. + au_writel(0x00, 0xb0300000); /* aes */
  1076. + au_writel(0x00, 0xb4004000); /* cim */
  1077. + au_writel(0x00, 0xb1100100); /* uart0_enable */
  1078. + au_writel(0x00, 0xb1200100); /* uart1_enable */
  1079. + au_writel(0x00, 0xb1900020); /* sys_freqctrl0 */
  1080. + au_writel(0x00, 0xb1900024); /* sys_freqctrl1 */
  1081. + au_writel(0x00, 0xb1900028); /* sys_clksrc */
  1082. + au_writel(0x10, 0xb1900060); /* sys_cpupll */
  1083. + au_writel(0x00, 0xb1900064); /* sys_auxpll */
  1084. + au_writel(0x00, 0xb1900100); /* sys_pininputen */
  1085. + break;
  1086. default:
  1087. break;
  1088. @@ -163,32 +181,23 @@ void au1000_restart(char *command)
  1089. void au1000_halt(void)
  1090. {
  1091. -#if defined(CONFIG_MIPS_PB1550)
  1092. - /* power off system */
  1093. - printk("\n** Powering off Pb1550\n");
  1094. - au_writew(au_readw(0xAF00001C) | (3<<14), 0xAF00001C);
  1095. - au_sync();
  1096. - while(1); /* should not get here */
  1097. -#endif
  1098. - printk(KERN_NOTICE "\n** You can safely turn off the power\n");
  1099. -#ifdef CONFIG_MIPS_MIRAGE
  1100. - au_writel((1 << 26) | (1 << 10), GPIO2_OUTPUT);
  1101. -#endif
  1102. -#ifdef CONFIG_PM
  1103. - au_sleep();
  1104. -
  1105. - /* should not get here */
  1106. - printk(KERN_ERR "Unable to put cpu in sleep mode\n");
  1107. - while(1);
  1108. -#else
  1109. - while (1)
  1110. + /* Use WAIT in a low-power infinite spin loop */
  1111. + while (1) {
  1112. __asm__(".set\tmips3\n\t"
  1113. "wait\n\t"
  1114. ".set\tmips0");
  1115. -#endif
  1116. + }
  1117. }
  1118. void au1000_power_off(void)
  1119. {
  1120. + extern void board_power_off (void);
  1121. +
  1122. + printk(KERN_NOTICE "\n** You can safely turn off the power\n");
  1123. +
  1124. + /* Give board a chance to power-off */
  1125. + board_power_off();
  1126. +
  1127. + /* If board can't power-off, spin forever */
  1128. au1000_halt();
  1129. }
  1130. --- a/arch/mips/au1000/common/setup.c
  1131. +++ b/arch/mips/au1000/common/setup.c
  1132. @@ -174,6 +174,40 @@ void __init au1x00_setup(void)
  1133. initrd_end = (unsigned long)&__rd_end;
  1134. #endif
  1135. +#if defined(CONFIG_SOC_AU1200)
  1136. +#ifdef CONFIG_USB_EHCI_HCD
  1137. + if ((argptr = strstr(argptr, "usb_ehci=")) == NULL) {
  1138. + char usb_args[80];
  1139. + argptr = prom_getcmdline();
  1140. + memset(usb_args, 0, sizeof(usb_args));
  1141. + sprintf(usb_args, " usb_ehci=base:0x%x,len:0x%x,irq:%d",
  1142. + USB_EHCI_BASE, USB_EHCI_LEN, AU1000_USB_HOST_INT);
  1143. + strcat(argptr, usb_args);
  1144. + }
  1145. +#ifdef CONFIG_USB_AMD5536UDC
  1146. + /* enable EHC + OHC + UDC clocks, memory and bus mastering */
  1147. +/* au_writel( 0x00DF207F, USB_MSR_BASE + 4); */
  1148. + au_writel( 0xC0DF207F, USB_MSR_BASE + 4); // incl. prefetch
  1149. +#else
  1150. + /* enable EHC + OHC clocks, memory and bus mastering */
  1151. +/* au_writel( 0x00DB200F, USB_MSR_BASE + 4); */
  1152. + au_writel( 0xC0DB200F, USB_MSR_BASE + 4); /* incl. prefetch */
  1153. +#endif
  1154. + udelay(1000);
  1155. +
  1156. +#else /* CONFIG_USB_EHCI_HCD */
  1157. +
  1158. +#ifdef CONFIG_USB_AMD5536UDC
  1159. +#ifndef CONFIG_USB_OHCI
  1160. + /* enable UDC clocks, memory and bus mastering */
  1161. +/* au_writel( 0x00DC2070, USB_MSR_BASE + 4); */
  1162. + au_writel( 0xC0DC2070, USB_MSR_BASE + 4); // incl. prefetch
  1163. + udelay(1000);
  1164. +#endif
  1165. +#endif
  1166. +#endif /* CONFIG_USB_EHCI_HCD */
  1167. +#endif /* CONFIG_SOC_AU1200 */
  1168. +
  1169. #if defined (CONFIG_USB_OHCI) || defined (CONFIG_AU1X00_USB_DEVICE)
  1170. #ifdef CONFIG_USB_OHCI
  1171. if ((argptr = strstr(argptr, "usb_ohci=")) == NULL) {
  1172. @@ -187,19 +221,38 @@ void __init au1x00_setup(void)
  1173. #endif
  1174. #ifdef CONFIG_USB_OHCI
  1175. - // enable host controller and wait for reset done
  1176. +#if defined(CONFIG_SOC_AU1200)
  1177. +#ifndef CONFIG_USB_EHCI_HCD
  1178. +#ifdef CONFIG_USB_AMD5536UDC
  1179. + /* enable OHC + UDC clocks, memory and bus mastering */
  1180. +/* au_writel( 0x00DD2073, USB_MSR_BASE + 4); */
  1181. + au_writel( 0xC0DD2073, USB_MSR_BASE + 4); // incl. prefetch
  1182. +#else
  1183. + /* enable OHC clocks, memory and bus mastering */
  1184. + au_writel( 0x00D12003, USB_MSR_BASE + 4);
  1185. +#endif
  1186. + udelay(1000);
  1187. +printk("DEBUG: Reading Au1200 USB2 reg 0x%x\n", au_readl(USB_MSR_BASE + 4));
  1188. +#endif
  1189. +#else
  1190. + /* Au1000, Au1500, Au1100, Au1550 */
  1191. + /* enable host controller and wait for reset done */
  1192. au_writel(0x08, USB_HOST_CONFIG);
  1193. udelay(1000);
  1194. au_writel(0x0E, USB_HOST_CONFIG);
  1195. udelay(1000);
  1196. - au_readl(USB_HOST_CONFIG); // throw away first read
  1197. + au_readl(USB_HOST_CONFIG); /* throw away first read */
  1198. while (!(au_readl(USB_HOST_CONFIG) & 0x10))
  1199. au_readl(USB_HOST_CONFIG);
  1200. +#endif /* CONFIG_SOC_AU1200 */
  1201. #endif
  1202. -#endif // defined (CONFIG_USB_OHCI) || defined (CONFIG_AU1X00_USB_DEVICE)
  1203. +#else
  1204. +
  1205. +#endif /* defined (CONFIG_USB_OHCI) || defined (CONFIG_AU1X00_USB_DEVICE) */
  1206. +
  1207. #ifdef CONFIG_FB
  1208. - // Needed if PCI video card in use
  1209. + /* Needed if PCI video card in use */
  1210. conswitchp = &dummy_con;
  1211. #endif
  1212. @@ -209,8 +262,7 @@ void __init au1x00_setup(void)
  1213. #endif
  1214. #ifdef CONFIG_BLK_DEV_IDE
  1215. - /* Board setup takes precedence for unique devices.
  1216. - */
  1217. + /* Board setup takes precedence for unique devices. */
  1218. if ((ide_ops == NULL) || (ide_ops == &no_ide_ops))
  1219. ide_ops = &std_ide_ops;
  1220. #endif
  1221. --- a/arch/mips/au1000/common/sleeper.S
  1222. +++ b/arch/mips/au1000/common/sleeper.S
  1223. @@ -15,17 +15,48 @@
  1224. #include <asm/addrspace.h>
  1225. #include <asm/regdef.h>
  1226. #include <asm/stackframe.h>
  1227. +#include <asm/au1000.h>
  1228. +
  1229. +/*
  1230. + * Note: This file is *not* conditional on CONFIG_PM since Alchemy sleep
  1231. + * need not be tied to any particular power management scheme.
  1232. + */
  1233. +
  1234. + .extern ___flush_cache_all
  1235. .text
  1236. - .set macro
  1237. - .set noat
  1238. .align 5
  1239. -/* Save all of the processor general registers and go to sleep.
  1240. - * A wakeup condition will get us back here to restore the registers.
  1241. +/*
  1242. + * Save the processor general registers and go to sleep. A wakeup
  1243. + * condition will get us back here to restore the registers.
  1244. */
  1245. -LEAF(save_and_sleep)
  1246. +/* still need to fix alignment issues here */
  1247. +save_and_sleep_frmsz = 48
  1248. +NESTED(save_and_sleep, save_and_sleep_frmsz, ra)
  1249. + .set noreorder
  1250. + .set nomacro
  1251. + .set noat
  1252. + subu sp, save_and_sleep_frmsz
  1253. + sw ra, save_and_sleep_frmsz-4(sp)
  1254. + sw s0, save_and_sleep_frmsz-8(sp)
  1255. + sw s1, save_and_sleep_frmsz-12(sp)
  1256. + sw s2, save_and_sleep_frmsz-16(sp)
  1257. + sw s3, save_and_sleep_frmsz-20(sp)
  1258. + sw s4, save_and_sleep_frmsz-24(sp)
  1259. + sw s5, save_and_sleep_frmsz-28(sp)
  1260. + sw s6, save_and_sleep_frmsz-32(sp)
  1261. + sw s7, save_and_sleep_frmsz-36(sp)
  1262. + sw s8, save_and_sleep_frmsz-40(sp)
  1263. + sw gp, save_and_sleep_frmsz-44(sp)
  1264. +
  1265. + /* We only need to save the registers that the calling function
  1266. + * hasn't saved for us. 0 is always zero. 8 - 15, 24 and 25 are
  1267. + * temporaries and can be used without saving. 26 and 27 are reserved
  1268. + * for interrupt/trap handling and expected to change. 29 is the
  1269. + * stack pointer which is handled as a special case here.
  1270. + */
  1271. subu sp, PT_SIZE
  1272. sw $1, PT_R1(sp)
  1273. sw $2, PT_R2(sp)
  1274. @@ -34,14 +65,6 @@ LEAF(save_and_sleep)
  1275. sw $5, PT_R5(sp)
  1276. sw $6, PT_R6(sp)
  1277. sw $7, PT_R7(sp)
  1278. - sw $8, PT_R8(sp)
  1279. - sw $9, PT_R9(sp)
  1280. - sw $10, PT_R10(sp)
  1281. - sw $11, PT_R11(sp)
  1282. - sw $12, PT_R12(sp)
  1283. - sw $13, PT_R13(sp)
  1284. - sw $14, PT_R14(sp)
  1285. - sw $15, PT_R15(sp)
  1286. sw $16, PT_R16(sp)
  1287. sw $17, PT_R17(sp)
  1288. sw $18, PT_R18(sp)
  1289. @@ -50,32 +73,47 @@ LEAF(save_and_sleep)
  1290. sw $21, PT_R21(sp)
  1291. sw $22, PT_R22(sp)
  1292. sw $23, PT_R23(sp)
  1293. - sw $24, PT_R24(sp)
  1294. - sw $25, PT_R25(sp)
  1295. - sw $26, PT_R26(sp)
  1296. - sw $27, PT_R27(sp)
  1297. sw $28, PT_R28(sp)
  1298. - sw $29, PT_R29(sp)
  1299. sw $30, PT_R30(sp)
  1300. sw $31, PT_R31(sp)
  1301. +#define PT_C0STATUS PT_LO
  1302. +#define PT_CONTEXT PT_HI
  1303. +#define PT_PAGEMASK PT_EPC
  1304. +#define PT_CONFIG PT_BVADDR
  1305. mfc0 k0, CP0_STATUS
  1306. - sw k0, 0x20(sp)
  1307. + sw k0, PT_C0STATUS(sp) // 0x20
  1308. mfc0 k0, CP0_CONTEXT
  1309. - sw k0, 0x1c(sp)
  1310. + sw k0, PT_CONTEXT(sp) // 0x1c
  1311. mfc0 k0, CP0_PAGEMASK
  1312. - sw k0, 0x18(sp)
  1313. + sw k0, PT_PAGEMASK(sp) // 0x18
  1314. mfc0 k0, CP0_CONFIG
  1315. - sw k0, 0x14(sp)
  1316. + sw k0, PT_CONFIG(sp) // 0x14
  1317. +
  1318. + .set macro
  1319. + .set at
  1320. +
  1321. + li t0, SYS_SLPPWR
  1322. + sw zero, 0(t0) /* Get the processor ready to sleep */
  1323. + sync
  1324. /* Now set up the scratch registers so the boot rom will
  1325. * return to this point upon wakeup.
  1326. + * sys_scratch0 : SP
  1327. + * sys_scratch1 : RA
  1328. + */
  1329. + li t0, SYS_SCRATCH0
  1330. + li t1, SYS_SCRATCH1
  1331. + sw sp, 0(t0)
  1332. + la k0, resume_from_sleep
  1333. + sw k0, 0(t1)
  1334. +
  1335. +/*
  1336. + * Flush DCACHE to make sure context is in memory
  1337. */
  1338. - la k0, 1f
  1339. - lui k1, 0xb190
  1340. - ori k1, 0x18
  1341. - sw sp, 0(k1)
  1342. - ori k1, 0x1c
  1343. - sw k0, 0(k1)
  1344. + la t1,___flush_cache_all /* _flush_cache_all is a function pointer */
  1345. + lw t0,0(t1)
  1346. + jal t0
  1347. + nop
  1348. /* Put SDRAM into self refresh. Preload instructions into cache,
  1349. * issue a precharge, then auto refresh, then sleep commands to it.
  1350. @@ -88,30 +126,65 @@ LEAF(save_and_sleep)
  1351. cache 0x14, 96(t0)
  1352. .set mips0
  1353. + /* Put SDRAM to sleep */
  1354. sdsleep:
  1355. - lui k0, 0xb400
  1356. - sw zero, 0x001c(k0) /* Precharge */
  1357. - sw zero, 0x0020(k0) /* Auto refresh */
  1358. - sw zero, 0x0030(k0) /* SDRAM sleep */
  1359. + li a0, MEM_PHYS_ADDR
  1360. + or a0, a0, 0xA0000000
  1361. +#if defined(CONFIG_SOC_AU1000) || defined(CONFIG_SOC_AU1100) || defined(CONFIG_SOC_AU1500)
  1362. + lw k0, MEM_SDMODE0(a0)
  1363. + sw zero, MEM_SDPRECMD(a0) /* Precharge */
  1364. + sw zero, MEM_SDAUTOREF(a0) /* Auto Refresh */
  1365. + sw zero, MEM_SDSLEEP(a0) /* Sleep */
  1366. sync
  1367. -
  1368. - lui k1, 0xb190
  1369. - sw zero, 0x0078(k1) /* get ready to sleep */
  1370. +#endif
  1371. +#if defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200)
  1372. + sw zero, MEM_SDPRECMD(a0) /* Precharge */
  1373. + sw zero, MEM_SDSREF(a0)
  1374. +
  1375. + #lw t0, MEM_SDSTAT(a0)
  1376. + #and t0, t0, 0x01000000
  1377. + li t0, 0x01000000
  1378. +refresh_not_set:
  1379. + lw t1, MEM_SDSTAT(a0)
  1380. + and t2, t1, t0
  1381. + beq zero, t2, refresh_not_set
  1382. + nop
  1383. +
  1384. + li t0, ~0x30000000
  1385. + lw t1, MEM_SDCONFIGA(a0)
  1386. + and t1, t0, t1
  1387. + sw t1, MEM_SDCONFIGA(a0)
  1388. sync
  1389. - sw zero, 0x007c(k1) /* Put processor to sleep */
  1390. +#endif
  1391. +
  1392. + li t0, SYS_SLEEP
  1393. + sw zero, 0(t0) /* Put processor to sleep */
  1394. sync
  1395. + nop
  1396. + nop
  1397. + nop
  1398. + nop
  1399. + nop
  1400. + nop
  1401. + nop
  1402. + nop
  1403. +
  1404. /* This is where we return upon wakeup.
  1405. * Reload all of the registers and return.
  1406. */
  1407. -1: nop
  1408. - lw k0, 0x20(sp)
  1409. +resume_from_sleep:
  1410. + nop
  1411. + .set nomacro
  1412. + .set noat
  1413. +
  1414. + lw k0, PT_C0STATUS(sp) // 0x20
  1415. mtc0 k0, CP0_STATUS
  1416. - lw k0, 0x1c(sp)
  1417. + lw k0, PT_CONTEXT(sp) // 0x1c
  1418. mtc0 k0, CP0_CONTEXT
  1419. - lw k0, 0x18(sp)
  1420. + lw k0, PT_PAGEMASK(sp) // 0x18
  1421. mtc0 k0, CP0_PAGEMASK
  1422. - lw k0, 0x14(sp)
  1423. + lw k0, PT_CONFIG(sp) // 0x14
  1424. mtc0 k0, CP0_CONFIG
  1425. lw $1, PT_R1(sp)
  1426. lw $2, PT_R2(sp)
  1427. @@ -120,14 +193,6 @@ sdsleep:
  1428. lw $5, PT_R5(sp)
  1429. lw $6, PT_R6(sp)
  1430. lw $7, PT_R7(sp)
  1431. - lw $8, PT_R8(sp)
  1432. - lw $9, PT_R9(sp)
  1433. - lw $10, PT_R10(sp)
  1434. - lw $11, PT_R11(sp)
  1435. - lw $12, PT_R12(sp)
  1436. - lw $13, PT_R13(sp)
  1437. - lw $14, PT_R14(sp)
  1438. - lw $15, PT_R15(sp)
  1439. lw $16, PT_R16(sp)
  1440. lw $17, PT_R17(sp)
  1441. lw $18, PT_R18(sp)
  1442. @@ -136,15 +201,36 @@ sdsleep:
  1443. lw $21, PT_R21(sp)
  1444. lw $22, PT_R22(sp)
  1445. lw $23, PT_R23(sp)
  1446. - lw $24, PT_R24(sp)
  1447. - lw $25, PT_R25(sp)
  1448. - lw $26, PT_R26(sp)
  1449. - lw $27, PT_R27(sp)
  1450. lw $28, PT_R28(sp)
  1451. - lw $29, PT_R29(sp)
  1452. lw $30, PT_R30(sp)
  1453. lw $31, PT_R31(sp)
  1454. +
  1455. + .set macro
  1456. + .set at
  1457. +
  1458. + /* clear the wake source, but save it as the return value of the function */
  1459. + li t0, SYS_WAKESRC
  1460. + lw v0, 0(t0)
  1461. + sw v0, PT_R2(sp)
  1462. + sw zero, 0(t0)
  1463. +
  1464. addiu sp, PT_SIZE
  1465. + lw gp, save_and_sleep_frmsz-44(sp)
  1466. + lw s8, save_and_sleep_frmsz-40(sp)
  1467. + lw s7, save_and_sleep_frmsz-36(sp)
  1468. + lw s6, save_and_sleep_frmsz-32(sp)
  1469. + lw s5, save_and_sleep_frmsz-28(sp)
  1470. + lw s4, save_and_sleep_frmsz-24(sp)
  1471. + lw s3, save_and_sleep_frmsz-20(sp)
  1472. + lw s2, save_and_sleep_frmsz-16(sp)
  1473. + lw s1, save_and_sleep_frmsz-12(sp)
  1474. + lw s0, save_and_sleep_frmsz-8(sp)
  1475. + lw ra, save_and_sleep_frmsz-4(sp)
  1476. +
  1477. + addu sp, save_and_sleep_frmsz
  1478. jr ra
  1479. + nop
  1480. + .set reorder
  1481. END(save_and_sleep)
  1482. +
  1483. --- a/arch/mips/au1000/common/time.c
  1484. +++ b/arch/mips/au1000/common/time.c
  1485. @@ -50,7 +50,6 @@
  1486. #include <linux/mc146818rtc.h>
  1487. #include <linux/timex.h>
  1488. -extern void startup_match20_interrupt(void);
  1489. extern void do_softirq(void);
  1490. extern volatile unsigned long wall_jiffies;
  1491. unsigned long missed_heart_beats = 0;
  1492. @@ -59,14 +58,14 @@ static unsigned long r4k_offset; /* Amou
  1493. static unsigned long r4k_cur; /* What counter should be at next timer irq */
  1494. extern rwlock_t xtime_lock;
  1495. int no_au1xxx_32khz;
  1496. -void (*au1k_wait_ptr)(void);
  1497. +extern int allow_au1k_wait; /* default off for CP0 Counter */
  1498. /* Cycle counter value at the previous timer interrupt.. */
  1499. static unsigned int timerhi = 0, timerlo = 0;
  1500. #ifdef CONFIG_PM
  1501. #define MATCH20_INC 328
  1502. -extern void startup_match20_interrupt(void);
  1503. +extern void startup_match20_interrupt(void (*handler)(int, void *, struct pt_regs *));
  1504. static unsigned long last_pc0, last_match20;
  1505. #endif
  1506. @@ -385,7 +384,6 @@ void __init au1xxx_timer_setup(void)
  1507. {
  1508. unsigned int est_freq;
  1509. extern unsigned long (*do_gettimeoffset)(void);
  1510. - extern void au1k_wait(void);
  1511. printk("calculating r4koff... ");
  1512. r4k_offset = cal_r4koff();
  1513. @@ -437,9 +435,6 @@ void __init au1xxx_timer_setup(void)
  1514. au_writel(0, SYS_TOYWRITE);
  1515. while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C0S);
  1516. - au_writel(au_readl(SYS_WAKEMSK) | (1<<8), SYS_WAKEMSK);
  1517. - au_writel(~0, SYS_WAKESRC);
  1518. - au_sync();
  1519. while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20);
  1520. /* setup match20 to interrupt once every 10ms */
  1521. @@ -447,13 +442,13 @@ void __init au1xxx_timer_setup(void)
  1522. au_writel(last_match20 + MATCH20_INC, SYS_TOYMATCH2);
  1523. au_sync();
  1524. while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20);
  1525. - startup_match20_interrupt();
  1526. + startup_match20_interrupt(counter0_irq);
  1527. do_gettimeoffset = do_fast_pm_gettimeoffset;
  1528. /* We can use the real 'wait' instruction.
  1529. */
  1530. - au1k_wait_ptr = au1k_wait;
  1531. + allow_au1k_wait = 1;
  1532. }
  1533. #else
  1534. --- a/arch/mips/au1000/db1x00/board_setup.c
  1535. +++ b/arch/mips/au1000/db1x00/board_setup.c
  1536. @@ -46,10 +46,22 @@
  1537. #include <asm/au1000.h>
  1538. #include <asm/db1x00.h>
  1539. -extern struct rtc_ops no_rtc_ops;
  1540. +#if defined(CONFIG_BLK_DEV_IDE_AU1XXX) && defined(CONFIG_MIPS_DB1550)
  1541. +#include <asm/au1xxx_dbdma.h>
  1542. +extern struct ide_ops *ide_ops;
  1543. +extern struct ide_ops au1xxx_ide_ops;
  1544. +extern u32 au1xxx_ide_virtbase;
  1545. +extern u64 au1xxx_ide_physbase;
  1546. +extern int au1xxx_ide_irq;
  1547. +
  1548. +/* Ddma */
  1549. +chan_tab_t *ide_read_ch, *ide_write_ch;
  1550. +u32 au1xxx_ide_ddma_enable = 0, switch4ddma = 1; // PIO+ddma
  1551. +
  1552. +dbdev_tab_t new_dbdev_tab_element = { DSCR_CMD0_THROTTLE, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 };
  1553. +#endif /* end CONFIG_BLK_DEV_IDE_AU1XXX */
  1554. -/* not correct for db1550 */
  1555. -static BCSR * const bcsr = (BCSR *)0xAE000000;
  1556. +extern struct rtc_ops no_rtc_ops;
  1557. void board_reset (void)
  1558. {
  1559. @@ -57,6 +69,13 @@ void board_reset (void)
  1560. au_writel(0x00000000, 0xAE00001C);
  1561. }
  1562. +void board_power_off (void)
  1563. +{
  1564. +#ifdef CONFIG_MIPS_MIRAGE
  1565. + au_writel((1 << 26) | (1 << 10), GPIO2_OUTPUT);
  1566. +#endif
  1567. +}
  1568. +
  1569. void __init board_setup(void)
  1570. {
  1571. u32 pin_func;
  1572. @@ -108,8 +127,42 @@ void __init board_setup(void)
  1573. au_writel(0x02000200, GPIO2_OUTPUT);
  1574. #endif
  1575. +#if def

Large files files are truncated, but you can click here to view the full file