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/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>
14 #include <linux/interrupt.h>
17 #include <asm/pgtable.h>
18 #include <asm/8xx_immap.h>
23 * I2C/SPI relocation patch arrays.
26 #ifdef CONFIG_I2C_SPI_UCODE_PATCH
28 static uint patch_2000[] __initdata = {
147 static uint patch_2f00[] __initdata = {
181 * I2C/SPI/SMC1 relocation patch arrays.
184 #ifdef CONFIG_I2C_SPI_SMC1_UCODE_PATCH
186 static uint patch_2000[] __initdata = {
509 static uint patch_2f00[] __initdata = {
576 static uint patch_2e00[] __initdata = {
597 * USB SOF patch arrays.
600 #ifdef CONFIG_USB_SOF_UCODE_PATCH
602 static uint patch_2000[] __initdata = {
617 static uint patch_2f00[] __initdata = {
624 void __init cpm_load_patch(cpm8xx_t *cp)
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)
631 volatile struct spi_pram *spp;
632 #ifdef CONFIG_I2C_SPI_SMC1_UCODE_PATCH
633 volatile smc_uart_t *smp;
640 #ifdef CONFIG_USB_SOF_UCODE_PATCH
641 commproc->cp_rccr = 0;
643 dp = (uint *)(commproc->cp_dpmem);
644 for (i=0; i<(sizeof(patch_2000)/4); i++)
645 *dp++ = patch_2000[i];
647 dp = (uint *)&(commproc->cp_dpmem[0x0f00]);
648 for (i=0; i<(sizeof(patch_2f00)/4); i++)
649 *dp++ = patch_2f00[i];
651 commproc->cp_rccr = 0x0009;
653 printk("USB SOF microcode patch installed\n");
654 #endif /* CONFIG_USB_SOF_UCODE_PATCH */
656 #if defined(CONFIG_I2C_SPI_UCODE_PATCH) || \
657 defined(CONFIG_I2C_SPI_SMC1_UCODE_PATCH)
659 commproc->cp_rccr = 0;
661 dp = (uint *)(commproc->cp_dpmem);
662 for (i=0; i<(sizeof(patch_2000)/4); i++)
663 *dp++ = patch_2000[i];
665 dp = (uint *)&(commproc->cp_dpmem[0x0f00]);
666 for (i=0; i<(sizeof(patch_2f00)/4); i++)
667 *dp++ = patch_2f00[i];
669 iip = (iic_t *)&commproc->cp_dparam[PROFF_IIC];
670 # define RPBASE 0x0500
671 iip->iic_rpbase = RPBASE;
673 /* Put SPI above the IIC, also 32-byte aligned.
675 i = (RPBASE + sizeof(iic_t) + 31) & ~31;
676 spp = (struct spi_pram *)&commproc->cp_dparam[PROFF_SPI];
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;
686 printk("I2C/SPI microcode patch installed.\n");
687 # endif /* CONFIG_I2C_SPI_UCODE_PATCH */
689 # if defined(CONFIG_I2C_SPI_SMC1_UCODE_PATCH)
691 dp = (uint *)&(commproc->cp_dpmem[0x0e00]);
692 for (i=0; i<(sizeof(patch_2e00)/4); i++)
693 *dp++ = patch_2e00[i];
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;
701 smp = (smc_uart_t *)&commproc->cp_dparam[PROFF_SMC1];
702 smp->smc_rpbase = 0x1FC0;
704 printk("I2C/SPI/SMC1 microcode patch installed.\n");
705 # endif /* CONFIG_I2C_SPI_SMC1_UCODE_PATCH) */
707 #endif /* some variation of the I2C/SPI patch was selected */
711 * Take this entire routine out, since no one calls it and its
717 verify_patch(volatile immap_t *immr)
720 volatile cpm8xx_t *commproc;
723 commproc = (cpm8xx_t *)&immr->im_cpm;
725 printk("cp_rccr %x\n", commproc->cp_rccr);
726 commproc->cp_rccr = 0;
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);
733 printk("found 0x%X, wanted 0x%X\n", *dp, patch_2000[i]);
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);
742 printk("found 0x%X, wanted 0x%X\n", *dp, patch_2f00[i]);
746 commproc->cp_rccr = 0x0009;