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