Linux Audio

Check our new training course

Loading...
Note: File does not exist in v6.8.
  1
  2/* Microcode patches for the CPM as supplied by Motorola.
  3 * This is the one for IIC/SPI.  There is a newer one that
  4 * also relocates SMC2, but this would require additional changes
  5 * to uart.c, so I am holding off on that for a moment.
  6 */
  7#include <linux/init.h>
  8#include <linux/errno.h>
  9#include <linux/sched.h>
 10#include <linux/kernel.h>
 11#include <linux/param.h>
 12#include <linux/string.h>
 13#include <linux/mm.h>
 14#include <linux/interrupt.h>
 15#include <asm/irq.h>
 16#include <asm/mpc8xx.h>
 17#include <asm/page.h>
 18#include <asm/pgtable.h>
 19#include <asm/8xx_immap.h>
 20#include <asm/cpm.h>
 21#include <asm/cpm1.h>
 22
 23/*
 24 * I2C/SPI relocation patch arrays.
 25 */
 26
 27#ifdef CONFIG_I2C_SPI_UCODE_PATCH
 28
 29static uint patch_2000[] __initdata = {
 30	0x7FFFEFD9,
 31	0x3FFD0000,
 32	0x7FFB49F7,
 33	0x7FF90000,
 34	0x5FEFADF7,
 35	0x5F89ADF7,
 36	0x5FEFAFF7,
 37	0x5F89AFF7,
 38	0x3A9CFBC8,
 39	0xE7C0EDF0,
 40	0x77C1E1BB,
 41	0xF4DC7F1D,
 42	0xABAD932F,
 43	0x4E08FDCF,
 44	0x6E0FAFF8,
 45	0x7CCF76CF,
 46	0xFD1FF9CF,
 47	0xABF88DC6,
 48	0xAB5679F7,
 49	0xB0937383,
 50	0xDFCE79F7,
 51	0xB091E6BB,
 52	0xE5BBE74F,
 53	0xB3FA6F0F,
 54	0x6FFB76CE,
 55	0xEE0DF9CF,
 56	0x2BFBEFEF,
 57	0xCFEEF9CF,
 58	0x76CEAD24,
 59	0x90B2DF9A,
 60	0x7FDDD0BF,
 61	0x4BF847FD,
 62	0x7CCF76CE,
 63	0xCFEF7E1F,
 64	0x7F1D7DFD,
 65	0xF0B6EF71,
 66	0x7FC177C1,
 67	0xFBC86079,
 68	0xE722FBC8,
 69	0x5FFFDFFF,
 70	0x5FB2FFFB,
 71	0xFBC8F3C8,
 72	0x94A67F01,
 73	0x7F1D5F39,
 74	0xAFE85F5E,
 75	0xFFDFDF96,
 76	0xCB9FAF7D,
 77	0x5FC1AFED,
 78	0x8C1C5FC1,
 79	0xAFDD5FC3,
 80	0xDF9A7EFD,
 81	0xB0B25FB2,
 82	0xFFFEABAD,
 83	0x5FB2FFFE,
 84	0x5FCE600B,
 85	0xE6BB600B,
 86	0x5FCEDFC6,
 87	0x27FBEFDF,
 88	0x5FC8CFDE,
 89	0x3A9CE7C0,
 90	0xEDF0F3C8,
 91	0x7F0154CD,
 92	0x7F1D2D3D,
 93	0x363A7570,
 94	0x7E0AF1CE,
 95	0x37EF2E68,
 96	0x7FEE10EC,
 97	0xADF8EFDE,
 98	0xCFEAE52F,
 99	0x7D0FE12B,
100	0xF1CE5F65,
101	0x7E0A4DF8,
102	0xCFEA5F72,
103	0x7D0BEFEE,
104	0xCFEA5F74,
105	0xE522EFDE,
106	0x5F74CFDA,
107	0x0B627385,
108	0xDF627E0A,
109	0x30D8145B,
110	0xBFFFF3C8,
111	0x5FFFDFFF,
112	0xA7F85F5E,
113	0xBFFE7F7D,
114	0x10D31450,
115	0x5F36BFFF,
116	0xAF785F5E,
117	0xBFFDA7F8,
118	0x5F36BFFE,
119	0x77FD30C0,
120	0x4E08FDCF,
121	0xE5FF6E0F,
122	0xAFF87E1F,
123	0x7E0FFD1F,
124	0xF1CF5F1B,
125	0xABF80D5E,
126	0x5F5EFFEF,
127	0x79F730A2,
128	0xAFDD5F34,
129	0x47F85F34,
130	0xAFED7FDD,
131	0x50B24978,
132	0x47FD7F1D,
133	0x7DFD70AD,
134	0xEF717EC1,
135	0x6BA47F01,
136	0x2D267EFD,
137	0x30DE5F5E,
138	0xFFFD5F5E,
139	0xFFEF5F5E,
140	0xFFDF0CA0,
141	0xAFED0A9E,
142	0xAFDD0C3A,
143	0x5F3AAFBD,
144	0x7FBDB082,
145	0x5F8247F8
146};
147
148static uint patch_2f00[] __initdata = {
149	0x3E303430,
150	0x34343737,
151	0xABF7BF9B,
152	0x994B4FBD,
153	0xBD599493,
154	0x349FFF37,
155	0xFB9B177D,
156	0xD9936956,
157	0xBBFDD697,
158	0xBDD2FD11,
159	0x31DB9BB3,
160	0x63139637,
161	0x93733693,
162	0x193137F7,
163	0x331737AF,
164	0x7BB9B999,
165	0xBB197957,
166	0x7FDFD3D5,
167	0x73B773F7,
168	0x37933B99,
169	0x1D115316,
170	0x99315315,
171	0x31694BF4,
172	0xFBDBD359,
173	0x31497353,
174	0x76956D69,
175	0x7B9D9693,
176	0x13131979,
177	0x79376935
178};
179#endif
180
181/*
182 * I2C/SPI/SMC1 relocation patch arrays.
183 */
184
185#ifdef CONFIG_I2C_SPI_SMC1_UCODE_PATCH
186
187static uint patch_2000[] __initdata = {
188	0x3fff0000,
189	0x3ffd0000,
190	0x3ffb0000,
191	0x3ff90000,
192	0x5f13eff8,
193	0x5eb5eff8,
194	0x5f88adf7,
195	0x5fefadf7,
196	0x3a9cfbc8,
197	0x77cae1bb,
198	0xf4de7fad,
199	0xabae9330,
200	0x4e08fdcf,
201	0x6e0faff8,
202	0x7ccf76cf,
203	0xfdaff9cf,
204	0xabf88dc8,
205	0xab5879f7,
206	0xb0925d8d,
207	0xdfd079f7,
208	0xb090e6bb,
209	0xe5bbe74f,
210	0x9e046f0f,
211	0x6ffb76ce,
212	0xee0cf9cf,
213	0x2bfbefef,
214	0xcfeef9cf,
215	0x76cead23,
216	0x90b3df99,
217	0x7fddd0c1,
218	0x4bf847fd,
219	0x7ccf76ce,
220	0xcfef77ca,
221	0x7eaf7fad,
222	0x7dfdf0b7,
223	0xef7a7fca,
224	0x77cafbc8,
225	0x6079e722,
226	0xfbc85fff,
227	0xdfff5fb3,
228	0xfffbfbc8,
229	0xf3c894a5,
230	0xe7c9edf9,
231	0x7f9a7fad,
232	0x5f36afe8,
233	0x5f5bffdf,
234	0xdf95cb9e,
235	0xaf7d5fc3,
236	0xafed8c1b,
237	0x5fc3afdd,
238	0x5fc5df99,
239	0x7efdb0b3,
240	0x5fb3fffe,
241	0xabae5fb3,
242	0xfffe5fd0,
243	0x600be6bb,
244	0x600b5fd0,
245	0xdfc827fb,
246	0xefdf5fca,
247	0xcfde3a9c,
248	0xe7c9edf9,
249	0xf3c87f9e,
250	0x54ca7fed,
251	0x2d3a3637,
252	0x756f7e9a,
253	0xf1ce37ef,
254	0x2e677fee,
255	0x10ebadf8,
256	0xefdecfea,
257	0xe52f7d9f,
258	0xe12bf1ce,
259	0x5f647e9a,
260	0x4df8cfea,
261	0x5f717d9b,
262	0xefeecfea,
263	0x5f73e522,
264	0xefde5f73,
265	0xcfda0b61,
266	0x5d8fdf61,
267	0xe7c9edf9,
268	0x7e9a30d5,
269	0x1458bfff,
270	0xf3c85fff,
271	0xdfffa7f8,
272	0x5f5bbffe,
273	0x7f7d10d0,
274	0x144d5f33,
275	0xbfffaf78,
276	0x5f5bbffd,
277	0xa7f85f33,
278	0xbffe77fd,
279	0x30bd4e08,
280	0xfdcfe5ff,
281	0x6e0faff8,
282	0x7eef7e9f,
283	0xfdeff1cf,
284	0x5f17abf8,
285	0x0d5b5f5b,
286	0xffef79f7,
287	0x309eafdd,
288	0x5f3147f8,
289	0x5f31afed,
290	0x7fdd50af,
291	0x497847fd,
292	0x7f9e7fed,
293	0x7dfd70a9,
294	0xef7e7ece,
295	0x6ba07f9e,
296	0x2d227efd,
297	0x30db5f5b,
298	0xfffd5f5b,
299	0xffef5f5b,
300	0xffdf0c9c,
301	0xafed0a9a,
302	0xafdd0c37,
303	0x5f37afbd,
304	0x7fbdb081,
305	0x5f8147f8,
306	0x3a11e710,
307	0xedf0ccdd,
308	0xf3186d0a,
309	0x7f0e5f06,
310	0x7fedbb38,
311	0x3afe7468,
312	0x7fedf4fc,
313	0x8ffbb951,
314	0xb85f77fd,
315	0xb0df5ddd,
316	0xdefe7fed,
317	0x90e1e74d,
318	0x6f0dcbf7,
319	0xe7decfed,
320	0xcb74cfed,
321	0xcfeddf6d,
322	0x91714f74,
323	0x5dd2deef,
324	0x9e04e7df,
325	0xefbb6ffb,
326	0xe7ef7f0e,
327	0x9e097fed,
328	0xebdbeffa,
329	0xeb54affb,
330	0x7fea90d7,
331	0x7e0cf0c3,
332	0xbffff318,
333	0x5fffdfff,
334	0xac59efea,
335	0x7fce1ee5,
336	0xe2ff5ee1,
337	0xaffbe2ff,
338	0x5ee3affb,
339	0xf9cc7d0f,
340	0xaef8770f,
341	0x7d0fb0c6,
342	0xeffbbfff,
343	0xcfef5ede,
344	0x7d0fbfff,
345	0x5ede4cf8,
346	0x7fddd0bf,
347	0x49f847fd,
348	0x7efdf0bb,
349	0x7fedfffd,
350	0x7dfdf0b7,
351	0xef7e7e1e,
352	0x5ede7f0e,
353	0x3a11e710,
354	0xedf0ccab,
355	0xfb18ad2e,
356	0x1ea9bbb8,
357	0x74283b7e,
358	0x73c2e4bb,
359	0x2ada4fb8,
360	0xdc21e4bb,
361	0xb2a1ffbf,
362	0x5e2c43f8,
363	0xfc87e1bb,
364	0xe74ffd91,
365	0x6f0f4fe8,
366	0xc7ba32e2,
367	0xf396efeb,
368	0x600b4f78,
369	0xe5bb760b,
370	0x53acaef8,
371	0x4ef88b0e,
372	0xcfef9e09,
373	0xabf8751f,
374	0xefef5bac,
375	0x741f4fe8,
376	0x751e760d,
377	0x7fdbf081,
378	0x741cafce,
379	0xefcc7fce,
380	0x751e70ac,
381	0x741ce7bb,
382	0x3372cfed,
383	0xafdbefeb,
384	0xe5bb760b,
385	0x53f2aef8,
386	0xafe8e7eb,
387	0x4bf8771e,
388	0x7e247fed,
389	0x4fcbe2cc,
390	0x7fbc30a9,
391	0x7b0f7a0f,
392	0x34d577fd,
393	0x308b5db7,
394	0xde553e5f,
395	0xaf78741f,
396	0x741f30f0,
397	0xcfef5e2c,
398	0x741f3eac,
399	0xafb8771e,
400	0x5e677fed,
401	0x0bd3e2cc,
402	0x741ccfec,
403	0xe5ca53cd,
404	0x6fcb4f74,
405	0x5dadde4b,
406	0x2ab63d38,
407	0x4bb3de30,
408	0x751f741c,
409	0x6c42effa,
410	0xefea7fce,
411	0x6ffc30be,
412	0xefec3fca,
413	0x30b3de2e,
414	0xadf85d9e,
415	0xaf7daefd,
416	0x5d9ede2e,
417	0x5d9eafdd,
418	0x761f10ac,
419	0x1da07efd,
420	0x30adfffe,
421	0x4908fb18,
422	0x5fffdfff,
423	0xafbb709b,
424	0x4ef85e67,
425	0xadf814ad,
426	0x7a0f70ad,
427	0xcfef50ad,
428	0x7a0fde30,
429	0x5da0afed,
430	0x3c12780f,
431	0xefef780f,
432	0xefef790f,
433	0xa7f85e0f,
434	0xffef790f,
435	0xefef790f,
436	0x14adde2e,
437	0x5d9eadfd,
438	0x5e2dfffb,
439	0xe79addfd,
440	0xeff96079,
441	0x607ae79a,
442	0xddfceff9,
443	0x60795dff,
444	0x607acfef,
445	0xefefefdf,
446	0xefbfef7f,
447	0xeeffedff,
448	0xebffe7ff,
449	0xafefafdf,
450	0xafbfaf7f,
451	0xaeffadff,
452	0xabffa7ff,
453	0x6fef6fdf,
454	0x6fbf6f7f,
455	0x6eff6dff,
456	0x6bff67ff,
457	0x2fef2fdf,
458	0x2fbf2f7f,
459	0x2eff2dff,
460	0x2bff27ff,
461	0x4e08fd1f,
462	0xe5ff6e0f,
463	0xaff87eef,
464	0x7e0ffdef,
465	0xf11f6079,
466	0xabf8f542,
467	0x7e0af11c,
468	0x37cfae3a,
469	0x7fec90be,
470	0xadf8efdc,
471	0xcfeae52f,
472	0x7d0fe12b,
473	0xf11c6079,
474	0x7e0a4df8,
475	0xcfea5dc4,
476	0x7d0befec,
477	0xcfea5dc6,
478	0xe522efdc,
479	0x5dc6cfda,
480	0x4e08fd1f,
481	0x6e0faff8,
482	0x7c1f761f,
483	0xfdeff91f,
484	0x6079abf8,
485	0x761cee24,
486	0xf91f2bfb,
487	0xefefcfec,
488	0xf91f6079,
489	0x761c27fb,
490	0xefdf5da7,
491	0xcfdc7fdd,
492	0xd09c4bf8,
493	0x47fd7c1f,
494	0x761ccfcf,
495	0x7eef7fed,
496	0x7dfdf093,
497	0xef7e7f1e,
498	0x771efb18,
499	0x6079e722,
500	0xe6bbe5bb,
501	0xae0ae5bb,
502	0x600bae85,
503	0xe2bbe2bb,
504	0xe2bbe2bb,
505	0xaf02e2bb,
506	0xe2bb2ff9,
507	0x6079e2bb
508};
509
510static uint patch_2f00[] __initdata = {
511	0x30303030,
512	0x3e3e3434,
513	0xabbf9b99,
514	0x4b4fbdbd,
515	0x59949334,
516	0x9fff37fb,
517	0x9b177dd9,
518	0x936956bb,
519	0xfbdd697b,
520	0xdd2fd113,
521	0x1db9f7bb,
522	0x36313963,
523	0x79373369,
524	0x3193137f,
525	0x7331737a,
526	0xf7bb9b99,
527	0x9bb19795,
528	0x77fdfd3d,
529	0x573b773f,
530	0x737933f7,
531	0xb991d115,
532	0x31699315,
533	0x31531694,
534	0xbf4fbdbd,
535	0x35931497,
536	0x35376956,
537	0xbd697b9d,
538	0x96931313,
539	0x19797937,
540	0x6935af78,
541	0xb9b3baa3,
542	0xb8788683,
543	0x368f78f7,
544	0x87778733,
545	0x3ffffb3b,
546	0x8e8f78b8,
547	0x1d118e13,
548	0xf3ff3f8b,
549	0x6bd8e173,
550	0xd1366856,
551	0x68d1687b,
552	0x3daf78b8,
553	0x3a3a3f87,
554	0x8f81378f,
555	0xf876f887,
556	0x77fd8778,
557	0x737de8d6,
558	0xbbf8bfff,
559	0xd8df87f7,
560	0xfd876f7b,
561	0x8bfff8bd,
562	0x8683387d,
563	0xb873d87b,
564	0x3b8fd7f8,
565	0xf7338883,
566	0xbb8ee1f8,
567	0xef837377,
568	0x3337b836,
569	0x817d11f8,
570	0x7378b878,
571	0xd3368b7d,
572	0xed731b7d,
573	0x833731f3,
574	0xf22f3f23
575};
576
577static uint patch_2e00[] __initdata = {
578	0x27eeeeee,
579	0xeeeeeeee,
580	0xeeeeeeee,
581	0xeeeeeeee,
582	0xee4bf4fb,
583	0xdbd259bb,
584	0x1979577f,
585	0xdfd2d573,
586	0xb773f737,
587	0x4b4fbdbd,
588	0x25b9b177,
589	0xd2d17376,
590	0x956bbfdd,
591	0x697bdd2f,
592	0xff9f79ff,
593	0xff9ff22f
594};
595#endif
596
597/*
598 *  USB SOF patch arrays.
599 */
600
601#ifdef CONFIG_USB_SOF_UCODE_PATCH
602
603static uint patch_2000[] __initdata = {
604	0x7fff0000,
605	0x7ffd0000,
606	0x7ffb0000,
607	0x49f7ba5b,
608	0xba383ffb,
609	0xf9b8b46d,
610	0xe5ab4e07,
611	0xaf77bffe,
612	0x3f7bbf79,
613	0xba5bba38,
614	0xe7676076,
615	0x60750000
616};
617
618static uint patch_2f00[] __initdata = {
619	0x3030304c,
620	0xcab9e441,
621	0xa1aaf220
622};
623#endif
624
625void __init cpm_load_patch(cpm8xx_t *cp)
626{
627	volatile uint		*dp;		/* Dual-ported RAM. */
628	volatile cpm8xx_t	*commproc;
629#if defined(CONFIG_I2C_SPI_UCODE_PATCH) || \
630    defined(CONFIG_I2C_SPI_SMC1_UCODE_PATCH)
631	volatile iic_t		*iip;
632	volatile struct spi_pram *spp;
633#ifdef CONFIG_I2C_SPI_SMC1_UCODE_PATCH
634	volatile smc_uart_t	*smp;
635#endif
636#endif
637	int	i;
638
639	commproc = cp;
640
641#ifdef CONFIG_USB_SOF_UCODE_PATCH
642	commproc->cp_rccr = 0;
643
644	dp = (uint *)(commproc->cp_dpmem);
645	for (i=0; i<(sizeof(patch_2000)/4); i++)
646		*dp++ = patch_2000[i];
647
648	dp = (uint *)&(commproc->cp_dpmem[0x0f00]);
649	for (i=0; i<(sizeof(patch_2f00)/4); i++)
650		*dp++ = patch_2f00[i];
651
652	commproc->cp_rccr = 0x0009;
653
654	printk("USB SOF microcode patch installed\n");
655#endif /* CONFIG_USB_SOF_UCODE_PATCH */
656
657#if defined(CONFIG_I2C_SPI_UCODE_PATCH) || \
658    defined(CONFIG_I2C_SPI_SMC1_UCODE_PATCH)
659
660	commproc->cp_rccr = 0;
661
662	dp = (uint *)(commproc->cp_dpmem);
663	for (i=0; i<(sizeof(patch_2000)/4); i++)
664		*dp++ = patch_2000[i];
665
666	dp = (uint *)&(commproc->cp_dpmem[0x0f00]);
667	for (i=0; i<(sizeof(patch_2f00)/4); i++)
668		*dp++ = patch_2f00[i];
669
670	iip = (iic_t *)&commproc->cp_dparam[PROFF_IIC];
671# define RPBASE 0x0500
672	iip->iic_rpbase = RPBASE;
673
674	/* Put SPI above the IIC, also 32-byte aligned.
675	*/
676	i = (RPBASE + sizeof(iic_t) + 31) & ~31;
677	spp = (struct spi_pram *)&commproc->cp_dparam[PROFF_SPI];
678	spp->rpbase = i;
679
680# if defined(CONFIG_I2C_SPI_UCODE_PATCH)
681	commproc->cp_cpmcr1 = 0x802a;
682	commproc->cp_cpmcr2 = 0x8028;
683	commproc->cp_cpmcr3 = 0x802e;
684	commproc->cp_cpmcr4 = 0x802c;
685	commproc->cp_rccr = 1;
686
687	printk("I2C/SPI microcode patch installed.\n");
688# endif /* CONFIG_I2C_SPI_UCODE_PATCH */
689
690# if defined(CONFIG_I2C_SPI_SMC1_UCODE_PATCH)
691
692	dp = (uint *)&(commproc->cp_dpmem[0x0e00]);
693	for (i=0; i<(sizeof(patch_2e00)/4); i++)
694		*dp++ = patch_2e00[i];
695
696	commproc->cp_cpmcr1 = 0x8080;
697	commproc->cp_cpmcr2 = 0x808a;
698	commproc->cp_cpmcr3 = 0x8028;
699	commproc->cp_cpmcr4 = 0x802a;
700	commproc->cp_rccr = 3;
701
702	smp = (smc_uart_t *)&commproc->cp_dparam[PROFF_SMC1];
703	smp->smc_rpbase = 0x1FC0;
704
705	printk("I2C/SPI/SMC1 microcode patch installed.\n");
706# endif /* CONFIG_I2C_SPI_SMC1_UCODE_PATCH) */
707
708#endif /* some variation of the I2C/SPI patch was selected */
709}
710
711/*
712 *  Take this entire routine out, since no one calls it and its
713 * logic is suspect.
714 */
715
716#if 0
717void
718verify_patch(volatile immap_t *immr)
719{
720	volatile uint		*dp;
721	volatile cpm8xx_t	*commproc;
722	int i;
723
724	commproc = (cpm8xx_t *)&immr->im_cpm;
725
726	printk("cp_rccr %x\n", commproc->cp_rccr);
727	commproc->cp_rccr = 0;
728
729	dp = (uint *)(commproc->cp_dpmem);
730	for (i=0; i<(sizeof(patch_2000)/4); i++)
731		if (*dp++ != patch_2000[i]) {
732			printk("patch_2000 bad at %d\n", i);
733			dp--;
734			printk("found 0x%X, wanted 0x%X\n", *dp, patch_2000[i]);
735			break;
736		}
737
738	dp = (uint *)&(commproc->cp_dpmem[0x0f00]);
739	for (i=0; i<(sizeof(patch_2f00)/4); i++)
740		if (*dp++ != patch_2f00[i]) {
741			printk("patch_2f00 bad at %d\n", i);
742			dp--;
743			printk("found 0x%X, wanted 0x%X\n", *dp, patch_2f00[i]);
744			break;
745		}
746
747	commproc->cp_rccr = 0x0009;
748}
749#endif