23 #include <linux/kernel.h>
28 #include <asm/fixmap.h>
29 #include <asm/pgtable.h>
32 #define MRST_SPI_TIMEOUT 0x200000
33 #define MRST_REGBASE_SPI0 0xff128000
34 #define MRST_REGBASE_SPI1 0xff128400
35 #define MRST_CLK_SPI0_REG 0xff11d86c
38 #define SPI_DFS_OFFSET 0
40 #define SPI_FRF_OFFSET 4
41 #define SPI_FRF_SPI 0x0
42 #define SPI_FRF_SSP 0x1
43 #define SPI_FRF_MICROWIRE 0x2
44 #define SPI_FRF_RESV 0x3
46 #define SPI_MODE_OFFSET 6
47 #define SPI_SCPH_OFFSET 6
48 #define SPI_SCOL_OFFSET 7
49 #define SPI_TMOD_OFFSET 8
50 #define SPI_TMOD_TR 0x0
51 #define SPI_TMOD_TO 0x1
52 #define SPI_TMOD_RO 0x2
53 #define SPI_TMOD_EPROMREAD 0x3
55 #define SPI_SLVOE_OFFSET 10
56 #define SPI_SRL_OFFSET 11
57 #define SPI_CFS_OFFSET 12
61 #define SR_BUSY (1 << 0)
62 #define SR_TF_NOT_FULL (1 << 1)
63 #define SR_TF_EMPT (1 << 2)
64 #define SR_RF_NOT_EMPT (1 << 3)
65 #define SR_RF_FULL (1 << 4)
66 #define SR_TX_ERR (1 << 5)
67 #define SR_DCOL (1 << 6)
99 #define dw_readl(dw, name) __raw_readl(&(dw)->name)
100 #define dw_writel(dw, name, val) __raw_writel((val), &(dw)->name)
105 static u32 *pclk_spi0;
110 static int dumper_registered;
112 static void dw_kmsg_dump(
struct kmsg_dumper *dumper,
115 static char line[1024];
121 while (kmsg_dump_get_line(dumper,
true, line,
sizeof(line), &len))
126 static void max3110_write_config(
void)
135 static void max3110_write_data(
char c)
152 spi0_cdiv = ((*pclk_spi0) & 0xe00) >> 9;
153 freq = 100000000 / (spi0_cdiv + 1);
189 max3110_write_config();
192 if (!dumper_registered) {
193 dw_dumper.dump = dw_kmsg_dump;
194 kmsg_dump_register(&dw_dumper);
195 dumper_registered = 1;
200 static void early_mrst_spi_putc(
char c)
218 max3110_write_data(c);
222 static void early_mrst_spi_write(
struct console *
con,
const char *
str,
unsigned n)
226 for (i = 0; i < n && *
str; i++) {
228 early_mrst_spi_putc(
'\r');
229 early_mrst_spi_putc(*str);
236 .write = early_mrst_spi_write,
245 #define HSU_PORT_BASE 0xffa28080
258 if (*s && !kstrtoul(s, 10, &port))
288 #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
290 static void early_hsu_putc(
char ch)
292 unsigned int timeout = 10000;
307 static void early_hsu_write(
struct console *con,
const char *str,
unsigned n)
311 for (i = 0; i < n && *
str; i++) {
313 early_hsu_putc(
'\r');
314 early_hsu_putc(*str);
321 .write = early_hsu_write,