74 static struct cpm_bd *tbdf, *rbdf;
76 static void *cbd_addr;
77 static u32 cbd_offset;
79 static void (*do_cmd)(
int op);
83 #define CPM_CMD_STOP_TX 4
84 #define CPM_CMD_RESTART_TX 6
85 #define CPM_CMD_INIT_RX_TX 0
87 static void cpm1_cmd(
int op)
92 out_be16(cpcr, (op << 8) | cpm_cmd | 1);
98 static void cpm2_cmd(
int op)
100 while (
in_be32(cpcr) & 0x10000)
103 out_be32(cpcr, op | cpm_cmd | 0x10000);
105 while (
in_be32(cpcr) & 0x10000)
109 static void smc_disable_port(
void)
115 static void scc_disable_port(
void)
121 static void smc_enable_port(
void)
127 static void scc_enable_port(
void)
133 static int cpm_serial_open(
void)
146 rbdf->
addr = (
u8 *)rbdf - 1;
151 tbdf->
addr = (
u8 *)rbdf - 2;
165 static void cpm_serial_putc(
unsigned char c)
167 while (tbdf->
sc & 0x8000)
177 static unsigned char cpm_serial_tstc(
void)
180 return !(rbdf->
sc & 0x8000);
183 static unsigned char cpm_serial_getc(
void)
187 while (!cpm_serial_tstc())
202 int is_smc = 0, is_cpm2 = 0;
205 unsigned long muram_offset, muram_size;
217 enable_port = smc_enable_port;
218 disable_port = smc_disable_port;
220 enable_port = scc_enable_port;
221 disable_port = scc_disable_port;
229 if (getprop(devp,
"fsl,cpm-command", &cpm_cmd, 4) < 4)
242 parent = get_parent(devp);
249 muram = finddevice(
"/soc/cpm/muram/data");
261 if (getprop(muram,
"reg", reg, 8) < 8)
264 muram_offset = reg[0];
272 cbd_offset = muram_offset + muram_size - 2 *
sizeof(
struct cpm_bd);
274 if (is_cpm2 && is_smc) {
275 u16 *smc_base = (
u16 *)param;
278 pram_offset = cbd_offset - 64;
283 param = muram_addr - muram_offset + pram_offset;
286 cbd_addr = muram_addr - muram_offset + cbd_offset;
288 scdp->
open = cpm_serial_open;
289 scdp->
putc = cpm_serial_putc;
290 scdp->
getc = cpm_serial_getc;
291 scdp->
tstc = cpm_serial_tstc;