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.
7 #include <linux/config.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>
14 #include <linux/interrupt.h>
16 #include <asm/mpc8xx.h>
18 #include <asm/pgtable.h>
19 #include <asm/8xx_immap.h>
20 #include <asm/commproc.h>
22 /* Define this to get SMC patches as well. You need to modify the uart
23 * driver as well......
24 #define USE_SMC_PATCH 1
27 #ifdef CONFIG_USB_MPC8xx
28 #define USE_USB_SOF_PATCH
153 uint patch_2f00
[] = {
187 #define PATCH_DEFINED
188 /* SMC2/IIC/SPI Patch */
189 /* This is the area from 0x2000 to 0x23ff.
191 uint patch_2000
[] = {
514 /* This is from 0x2f00 to 0x2fff
516 uint patch_2f00
[] = {
583 uint patch_2e00
[] = {
584 /* This is from 0x2e00 to 0x2e3c
605 #ifdef USE_USB_SOF_PATCH
606 #define PATCH_DEFINED
607 uint patch_2000
[] = {
622 uint patch_2f00
[] = {
629 /* Load the microcode patch. This is called early in the CPM initialization
630 * with the controller in the reset state. We enable the processor after
634 cpm_load_patch(volatile immap_t
*immr
)
638 volatile cpm8xx_t
*commproc
;
643 commproc
= (cpm8xx_t
*)&immr
->im_cpm
;
645 /* We work closely with commproc.c. We know it only allocates
646 * from data only space.
647 * For this particular patch, we only use the bottom 512 bytes
648 * and the upper 256 byte extension. We will use the space
649 * starting at 1K for the relocated parameters, as the general
650 * CPM allocation won't come from that area.
652 commproc
->cp_rccr
= 0;
654 /* Copy the patch into DPRAM.
656 dp
= (uint
*)(commproc
->cp_dpmem
);
657 for (i
=0; i
<(sizeof(patch_2000
)/4); i
++)
658 *dp
++ = patch_2000
[i
];
660 dp
= (uint
*)&(commproc
->cp_dpmem
[0x0f00]);
661 for (i
=0; i
<(sizeof(patch_2f00
)/4); i
++)
662 *dp
++ = patch_2f00
[i
];
664 #ifdef USE_USB_SOF_PATCH
665 #if 0 /* usb patch should not relocate iic */
666 iip
= (iic_t
*)&commproc
->cp_dparam
[PROFF_IIC
];
667 #define RPBASE 0x0030
668 iip
->iic_rpbase
= RPBASE
;
670 /* Put SPI above the IIC, also 32-byte aligned.
672 i
= (RPBASE
+ sizeof(iic_t
) + 31) & ~31;
673 spp
= (spi_t
*)&commproc
->cp_dparam
[PROFF_SPI
];
677 /* Enable uCode fetches from DPRAM. */
678 commproc
->cp_rccr
= 0x0009;
680 printk("USB uCode patch installed\n");
681 #endif /* USE_USB_SOF_PATCH */
683 #if defined(USE_SMC_PATCH) || defined(USE_IIC_PATCH)
685 iip
= (iic_t
*)&commproc
->cp_dparam
[PROFF_IIC
];
686 #define RPBASE 0x0400
687 iip
->iic_rpbase
= RPBASE
;
689 /* Put SPI above the IIC, also 32-byte aligned.
691 i
= (RPBASE
+ sizeof(iic_t
) + 31) & ~31;
692 spp
= (spi_t
*)&commproc
->cp_dparam
[PROFF_SPI
];
696 dp
= (uint
*)&(commproc
->cp_dpmem
[0x0e00]);
697 for (i
=0; i
<(sizeof(patch_2e00
)/4); i
++)
698 *dp
++ = patch_2e00
[i
];
700 /* Enable the traps to get to it.
702 commproc
->cp_cpmcr1
= 0x8080;
703 commproc
->cp_cpmcr2
= 0x808a;
704 commproc
->cp_cpmcr3
= 0x8028;
705 commproc
->cp_cpmcr4
= 0x802a;
707 /* Enable uCode fetches from DPRAM.
709 commproc
->cp_rccr
= 3;
713 /* Enable the traps to get to it.
715 commproc
->cp_cpmcr1
= 0x802a;
716 commproc
->cp_cpmcr2
= 0x8028;
717 commproc
->cp_cpmcr3
= 0x802e;
718 commproc
->cp_cpmcr4
= 0x802c;
720 /* Enable uCode fetches from DPRAM.
722 commproc
->cp_rccr
= 1;
724 printk("I2C uCode patch installed\n");
727 /* Relocate the IIC and SPI parameter areas. These have to
728 * aligned on 32-byte boundaries.
730 iip
= (iic_t
*)&commproc
->cp_dparam
[PROFF_IIC
];
731 iip
->iic_rpbase
= RPBASE
;
733 /* Put SPI above the IIC, also 32-byte aligned.
735 i
= (RPBASE
+ sizeof(iic_t
) + 31) & ~31;
736 spp
= (spi_t
*)&commproc
->cp_dparam
[PROFF_SPI
];
739 #endif /* USE_SMC_PATCH || USE_IIC_PATCH */
740 #endif /* PATCH_DEFINED */
744 verify_patch(volatile immap_t
*immr
)
748 volatile cpm8xx_t
*commproc
;
751 commproc
= (cpm8xx_t
*)&immr
->im_cpm
;
753 printk("cp_rccr %x\n", commproc
->cp_rccr
);
754 commproc
->cp_rccr
= 0;
756 dp
= (uint
*)(commproc
->cp_dpmem
);
757 for (i
=0; i
<(sizeof(patch_2000
)/4); i
++)
758 if (*dp
++ != patch_2000
[i
]) {
759 printk("patch_2000 bad at %d\n", i
);
761 printk("found 0x%X, wanted 0x%X\n", *dp
, patch_2000
[i
]);
765 dp
= (uint
*)&(commproc
->cp_dpmem
[0x0f00]);
766 for (i
=0; i
<(sizeof(patch_2f00
)/4); i
++)
767 if (*dp
++ != patch_2f00
[i
]) {
768 printk("patch_2f00 bad at %d\n", i
);
770 printk("found 0x%X, wanted 0x%X\n", *dp
, patch_2f00
[i
]);
774 commproc
->cp_rccr
= 0x0009;
775 #endif /* PATCH_DEFINED */