1 // SPDX-License-Identifier: GPL-2.0
4 * Microcode patches for the CPM as supplied by Motorola.
5 * This is the one for IIC/SPI. There is a newer one that
6 * also relocates SMC2, but this would require additional changes
7 * to uart.c, so I am holding off on that for a moment.
9 #include <linux/init.h>
10 #include <linux/errno.h>
11 #include <linux/sched.h>
12 #include <linux/kernel.h>
13 #include <linux/param.h>
14 #include <linux/string.h>
16 #include <linux/interrupt.h>
19 #include <asm/pgtable.h>
20 #include <asm/8xx_immap.h>
25 * I2C/SPI relocation patch arrays.
28 #ifdef CONFIG_I2C_SPI_UCODE_PATCH
30 static uint patch_2000[] __initdata = {
149 static uint patch_2f00[] __initdata = {
183 * I2C/SPI/SMC1 relocation patch arrays.
186 #ifdef CONFIG_I2C_SPI_SMC1_UCODE_PATCH
188 static uint patch_2000[] __initdata = {
511 static uint patch_2f00[] __initdata = {
578 static uint patch_2e00[] __initdata = {
599 * USB SOF patch arrays.
602 #ifdef CONFIG_USB_SOF_UCODE_PATCH
604 static uint patch_2000[] __initdata = {
619 static uint patch_2f00[] __initdata = {
626 void __init cpm_load_patch(cpm8xx_t *cp)
628 volatile uint *dp; /* Dual-ported RAM. */
629 volatile cpm8xx_t *commproc;
630 #if defined(CONFIG_I2C_SPI_UCODE_PATCH) || \
631 defined(CONFIG_I2C_SPI_SMC1_UCODE_PATCH)
633 volatile struct spi_pram *spp;
634 #ifdef CONFIG_I2C_SPI_SMC1_UCODE_PATCH
635 volatile smc_uart_t *smp;
642 #ifdef CONFIG_USB_SOF_UCODE_PATCH
643 commproc->cp_rccr = 0;
645 dp = (uint *)(commproc->cp_dpmem);
646 for (i=0; i<(sizeof(patch_2000)/4); i++)
647 *dp++ = patch_2000[i];
649 dp = (uint *)&(commproc->cp_dpmem[0x0f00]);
650 for (i=0; i<(sizeof(patch_2f00)/4); i++)
651 *dp++ = patch_2f00[i];
653 commproc->cp_rccr = 0x0009;
655 printk("USB SOF microcode patch installed\n");
656 #endif /* CONFIG_USB_SOF_UCODE_PATCH */
658 #if defined(CONFIG_I2C_SPI_UCODE_PATCH) || \
659 defined(CONFIG_I2C_SPI_SMC1_UCODE_PATCH)
661 commproc->cp_rccr = 0;
663 dp = (uint *)(commproc->cp_dpmem);
664 for (i=0; i<(sizeof(patch_2000)/4); i++)
665 *dp++ = patch_2000[i];
667 dp = (uint *)&(commproc->cp_dpmem[0x0f00]);
668 for (i=0; i<(sizeof(patch_2f00)/4); i++)
669 *dp++ = patch_2f00[i];
671 iip = (iic_t *)&commproc->cp_dparam[PROFF_IIC];
672 # define RPBASE 0x0500
673 iip->iic_rpbase = RPBASE;
675 /* Put SPI above the IIC, also 32-byte aligned.
677 i = (RPBASE + sizeof(iic_t) + 31) & ~31;
678 spp = (struct spi_pram *)&commproc->cp_dparam[PROFF_SPI];
681 # if defined(CONFIG_I2C_SPI_UCODE_PATCH)
682 commproc->cp_cpmcr1 = 0x802a;
683 commproc->cp_cpmcr2 = 0x8028;
684 commproc->cp_cpmcr3 = 0x802e;
685 commproc->cp_cpmcr4 = 0x802c;
686 commproc->cp_rccr = 1;
688 printk("I2C/SPI microcode patch installed.\n");
689 # endif /* CONFIG_I2C_SPI_UCODE_PATCH */
691 # if defined(CONFIG_I2C_SPI_SMC1_UCODE_PATCH)
693 dp = (uint *)&(commproc->cp_dpmem[0x0e00]);
694 for (i=0; i<(sizeof(patch_2e00)/4); i++)
695 *dp++ = patch_2e00[i];
697 commproc->cp_cpmcr1 = 0x8080;
698 commproc->cp_cpmcr2 = 0x808a;
699 commproc->cp_cpmcr3 = 0x8028;
700 commproc->cp_cpmcr4 = 0x802a;
701 commproc->cp_rccr = 3;
703 smp = (smc_uart_t *)&commproc->cp_dparam[PROFF_SMC1];
704 smp->smc_rpbase = 0x1FC0;
706 printk("I2C/SPI/SMC1 microcode patch installed.\n");
707 # endif /* CONFIG_I2C_SPI_SMC1_UCODE_PATCH) */
709 #endif /* some variation of the I2C/SPI patch was selected */