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
34 * I2C/SPI/SMC1 relocation patch arrays.
37 #ifdef CONFIG_I2C_SPI_SMC1_UCODE_PATCH
47 * USB SOF patch arrays.
50 #ifdef CONFIG_USB_SOF_UCODE_PATCH
57 void __init cpm_load_patch(cpm8xx_t *cp)
59 volatile uint *dp; /* Dual-ported RAM. */
60 volatile cpm8xx_t *commproc;
61 #if defined(CONFIG_I2C_SPI_UCODE_PATCH) || \
62 defined(CONFIG_I2C_SPI_SMC1_UCODE_PATCH)
64 volatile struct spi_pram *spp;
65 #ifdef CONFIG_I2C_SPI_SMC1_UCODE_PATCH
66 volatile smc_uart_t *smp;
73 #ifdef CONFIG_USB_SOF_UCODE_PATCH
74 commproc->cp_rccr = 0;
76 dp = (uint *)(commproc->cp_dpmem);
77 for (i=0; i<(sizeof(patch_2000)/4); i++)
78 *dp++ = patch_2000[i];
80 dp = (uint *)&(commproc->cp_dpmem[0x0f00]);
81 for (i=0; i<(sizeof(patch_2f00)/4); i++)
82 *dp++ = patch_2f00[i];
84 commproc->cp_rccr = 0x0009;
86 printk("USB SOF microcode patch installed\n");
87 #endif /* CONFIG_USB_SOF_UCODE_PATCH */
89 #if defined(CONFIG_I2C_SPI_UCODE_PATCH) || \
90 defined(CONFIG_I2C_SPI_SMC1_UCODE_PATCH)
92 commproc->cp_rccr = 0;
94 dp = (uint *)(commproc->cp_dpmem);
95 for (i=0; i<(sizeof(patch_2000)/4); i++)
96 *dp++ = patch_2000[i];
98 dp = (uint *)&(commproc->cp_dpmem[0x0f00]);
99 for (i=0; i<(sizeof(patch_2f00)/4); i++)
100 *dp++ = patch_2f00[i];
102 iip = (iic_t *)&commproc->cp_dparam[PROFF_IIC];
103 # define RPBASE 0x0500
104 iip->iic_rpbase = RPBASE;
106 /* Put SPI above the IIC, also 32-byte aligned.
108 i = (RPBASE + sizeof(iic_t) + 31) & ~31;
109 spp = (struct spi_pram *)&commproc->cp_dparam[PROFF_SPI];
112 # if defined(CONFIG_I2C_SPI_UCODE_PATCH)
113 commproc->cp_cpmcr1 = 0x802a;
114 commproc->cp_cpmcr2 = 0x8028;
115 commproc->cp_cpmcr3 = 0x802e;
116 commproc->cp_cpmcr4 = 0x802c;
117 commproc->cp_rccr = 1;
119 printk("I2C/SPI microcode patch installed.\n");
120 # endif /* CONFIG_I2C_SPI_UCODE_PATCH */
122 # if defined(CONFIG_I2C_SPI_SMC1_UCODE_PATCH)
124 dp = (uint *)&(commproc->cp_dpmem[0x0e00]);
125 for (i=0; i<(sizeof(patch_2e00)/4); i++)
126 *dp++ = patch_2e00[i];
128 commproc->cp_cpmcr1 = 0x8080;
129 commproc->cp_cpmcr2 = 0x808a;
130 commproc->cp_cpmcr3 = 0x8028;
131 commproc->cp_cpmcr4 = 0x802a;
132 commproc->cp_rccr = 3;
134 smp = (smc_uart_t *)&commproc->cp_dparam[PROFF_SMC1];
135 smp->smc_rpbase = 0x1FC0;
137 printk("I2C/SPI/SMC1 microcode patch installed.\n");
138 # endif /* CONFIG_I2C_SPI_SMC1_UCODE_PATCH) */
140 #endif /* some variation of the I2C/SPI patch was selected */
144 * Take this entire routine out, since no one calls it and its
150 verify_patch(volatile immap_t *immr)
153 volatile cpm8xx_t *commproc;
156 commproc = (cpm8xx_t *)&immr->im_cpm;
158 printk("cp_rccr %x\n", commproc->cp_rccr);
159 commproc->cp_rccr = 0;
161 dp = (uint *)(commproc->cp_dpmem);
162 for (i=0; i<(sizeof(patch_2000)/4); i++)
163 if (*dp++ != patch_2000[i]) {
164 printk("patch_2000 bad at %d\n", i);
166 printk("found 0x%X, wanted 0x%X\n", *dp, patch_2000[i]);
170 dp = (uint *)&(commproc->cp_dpmem[0x0f00]);
171 for (i=0; i<(sizeof(patch_2f00)/4); i++)
172 if (*dp++ != patch_2f00[i]) {
173 printk("patch_2f00 bad at %d\n", i);
175 printk("found 0x%X, wanted 0x%X\n", *dp, patch_2f00[i]);
179 commproc->cp_rccr = 0x0009;