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/8xx_immap.h>
32 * I2C/SPI relocation patch arrays.
35 #ifdef CONFIG_I2C_SPI_UCODE_PATCH
37 static char patch_name[] __initdata = "I2C/SPI";
39 static struct patch_params patch_params __initdata = {
40 1, 0x802a, 0x8028, 0x802e, 0x802c,
51 * I2C/SPI/SMC1 relocation patch arrays.
54 #ifdef CONFIG_I2C_SPI_SMC1_UCODE_PATCH
56 static char patch_name[] __initdata = "I2C/SPI/SMC1";
58 static struct patch_params patch_params __initdata = {
59 3, 0x8080, 0x808a, 0x8028, 0x802a,
70 * USB SOF patch arrays.
73 #ifdef CONFIG_USB_SOF_UCODE_PATCH
75 static char patch_name[] __initdata = "USB SOF";
77 static struct patch_params patch_params __initdata = {
89 * SMC relocation patch arrays.
92 #ifdef CONFIG_SMC_UCODE_PATCH
94 static char patch_name[] __initdata = "SMC";
96 static struct patch_params patch_params __initdata = {
107 static void __init cpm_write_patch(cpm8xx_t *cp, int offset, uint *patch, int len)
111 memcpy_toio(cp->cp_dpmem + offset, patch, len);
114 void __init cpm_load_patch(cpm8xx_t *cp)
116 out_be16(&cp->cp_rccr, 0);
122 if (IS_ENABLED(CONFIG_I2C_SPI_UCODE_PATCH) ||
123 IS_ENABLED(CONFIG_I2C_SPI_SMC1_UCODE_PATCH)) {
126 struct spi_pram *spp;
128 iip = (iic_t *)&cp->cp_dparam[PROFF_IIC];
129 out_be16(&iip->iic_rpbase, rpbase);
131 /* Put SPI above the IIC, also 32-byte aligned. */
132 spp = (struct spi_pram *)&cp->cp_dparam[PROFF_SPI];
133 out_be16(&spp->rpbase, (rpbase + sizeof(iic_t) + 31) & ~31);
135 if (IS_ENABLED(CONFIG_I2C_SPI_SMC1_UCODE_PATCH)) {
138 smp = (smc_uart_t *)&cp->cp_dparam[PROFF_SMC1];
139 out_be16(&smp->smc_rpbase, 0x1FC0);
143 if (IS_ENABLED(CONFIG_SMC_UCODE_PATCH)) {
146 if (IS_ENABLED(CONFIG_PPC_EARLY_DEBUG_CPM)) {
149 for (i = 0; i < sizeof(*smp); i += 4) {
150 u32 __iomem *src = (u32 __iomem *)&cp->cp_dparam[PROFF_SMC1 + i];
151 u32 __iomem *dst = (u32 __iomem *)&cp->cp_dparam[PROFF_DSP1 + i];
153 out_be32(dst, in_be32(src));
157 smp = (smc_uart_t *)&cp->cp_dparam[PROFF_SMC1];
158 out_be16(&smp->smc_rpbase, 0x1ec0);
159 smp = (smc_uart_t *)&cp->cp_dparam[PROFF_SMC2];
160 out_be16(&smp->smc_rpbase, 0x1fc0);
163 out_be16(&cp->cp_cpmcr1, patch_params.cpmcr1);
164 out_be16(&cp->cp_cpmcr2, patch_params.cpmcr2);
165 out_be16(&cp->cp_cpmcr3, patch_params.cpmcr3);
166 out_be16(&cp->cp_cpmcr4, patch_params.cpmcr4);
168 out_be16(&cp->cp_rccr, patch_params.rccr);
170 pr_info("%s microcode patch installed\n", patch_name);