blob: c40f7f0428c0b03832bf699a66c453bb2ac684b2 [file] [log] [blame]
Wolfgang Denk6617aae2005-08-19 00:46:54 +02001/*
2 * (C) Copyright 2005
3 * Martin Krause, TQ-Systems GmbH, martin.krause@tqs.de.
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24/*
Wolfgang Denk45a212c2006-07-19 17:52:30 +020025 * STK52XX specific functions
Wolfgang Denk6617aae2005-08-19 00:46:54 +020026 */
27/*#define DEBUG*/
28
29#include <common.h>
30#include <command.h>
31
Jon Loeligerab3abcb2007-07-09 18:45:16 -050032#if defined(CONFIG_CMD_BSP)
Wolfgang Denk6617aae2005-08-19 00:46:54 +020033
Marian Balakowicz6d3bc9b2006-08-18 19:14:46 +020034#if defined(CONFIG_STK52XX) || defined(CONFIG_FO300)
Wolfgang Denk6617aae2005-08-19 00:46:54 +020035#define DEFAULT_VOL 45
36#define DEFAULT_FREQ 500
37#define DEFAULT_DURATION 200
38#define LEFT 1
39#define RIGHT 2
40#define LEFT_RIGHT 3
41#define BL_OFF 0
42#define BL_ON 1
43
44#define SM501_GPIO_CTRL_LOW 0x00000008UL
45#define SM501_GPIO_CTRL_HIGH 0x0000000CUL
46#define SM501_POWER_MODE0_GATE 0x00000040UL
47#define SM501_POWER_MODE1_GATE 0x00000048UL
48#define POWER_MODE_GATE_GPIO_PWM_I2C 0x00000040UL
Wolfgang Denk53677ef2008-05-20 16:00:29 +020049#define SM501_GPIO_DATA_LOW 0x00010000UL
Wolfgang Denk6617aae2005-08-19 00:46:54 +020050#define SM501_GPIO_DATA_HIGH 0x00010004UL
51#define SM501_GPIO_DATA_DIR_LOW 0x00010008UL
52#define SM501_GPIO_DATA_DIR_HIGH 0x0001000CUL
53#define SM501_PANEL_DISPLAY_CONTROL 0x00080000UL
54
55static int i2s_squarewave(unsigned long duration, unsigned int freq,
56 unsigned int channel);
57static int i2s_sawtooth(unsigned long duration, unsigned int freq,
58 unsigned int channel);
59static void spi_init(void);
60static int spi_transmit(unsigned char data);
61static void pcm1772_write_reg(unsigned char addr, unsigned char data);
62static void set_attenuation(unsigned char attenuation);
63
Wolfgang Denk6617aae2005-08-19 00:46:54 +020064static void spi_init(void)
65{
66 struct mpc5xxx_spi *spi = (struct mpc5xxx_spi*)MPC5XXX_SPI;
67 struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio*)MPC5XXX_GPIO;
68
69 /* PSC3 as SPI and GPIOs */
70 gpio->port_config &= 0xFFFFF0FF;
71 gpio->port_config |= 0x00000800;
72 /*
73 * Its important to use the correct order when initializing the
74 * registers
75 */
76 spi->ddr = 0x0F; /* set all SPI pins as output */
77 spi->pdr = 0x08; /* set SS high */
78 spi->cr1 = 0x50; /* SPI is master, SS is general purpose output */
79 spi->cr2 = 0x00; /* normal operation */
80 spi->brr = 0xFF; /* baud rate: IPB clock / 2048 */
81}
82
83static int spi_transmit(unsigned char data)
84{
Wolfgang Denk6617aae2005-08-19 00:46:54 +020085 struct mpc5xxx_spi *spi = (struct mpc5xxx_spi*)MPC5XXX_SPI;
86
87 spi->dr = data;
88 /* wait for SPI transmission completed */
Wolfgang Denk65766f32011-11-04 15:55:09 +000089 while (!(spi->sr & 0x80)) {
90 if (spi->sr & 0x40) { /* if write collision occured */
91 int dummy;
92
Wolfgang Denk6617aae2005-08-19 00:46:54 +020093 /* do dummy read to clear status register */
94 dummy = spi->dr;
Wolfgang Denk65766f32011-11-04 15:55:09 +000095 printf("SPI write collision: dr=0x%x\n", dummy);
Wolfgang Denk6617aae2005-08-19 00:46:54 +020096 return -1;
97 }
98 }
99 return (spi->dr);
100}
101
102static void pcm1772_write_reg(unsigned char addr, unsigned char data)
103{
104 struct mpc5xxx_spi *spi = (struct mpc5xxx_spi*)MPC5XXX_SPI;
105
106 spi->pdr = 0x00; /* Set SS low */
107 spi_transmit(addr);
108 spi_transmit(data);
109 /* wait some time to meet MS# hold time of PCM1772 */
110 udelay (1);
111 spi->pdr = 0x08; /* set SS high */
112}
113
114static void set_attenuation(unsigned char attenuation)
115{
116 pcm1772_write_reg(0x01, attenuation); /* left channel */
117 debug ("PCM1772 attenuation left set to %d.\n", attenuation);
118 pcm1772_write_reg(0x02, attenuation); /* right channel */
119 debug ("PCM1772 attenuation right set to %d.\n", attenuation);
120}
121
122void amplifier_init(void)
123{
124 static int init_done = 0;
125 int i;
126 struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio*)MPC5XXX_GPIO;
127
128 /* Do this only once, because of the long time delay */
129 if (!init_done) {
130 /* configure PCM1772 audio format as I2S */
131 pcm1772_write_reg(0x03, 0x01);
132 /* enable audio amplifier */
133 gpio->sint_gpioe |= 0x02; /* PSC3_5 as GPIO */
134 gpio->sint_ode &= ~0x02; /* PSC3_5 is not open Drain */
135 gpio->sint_dvo &= ~0x02; /* PSC3_5 is LOW */
136 gpio->sint_ddr |= 0x02; /* PSC3_5 as output */
137 /*
138 * wait some time to allow amplifier to recover from shutdown
139 * mode.
140 */
141 for(i = 0; i < 350; i++)
142 udelay(1000);
143 /*
144 * The used amplifier (LM4867) has a so called "pop and click"
145 * elmination filter. The input signal of the amplifier must
146 * exceed a certain level once after power up to activate the
147 * generation of the output signal. This is achieved by
148 * sending a low frequent (nearly inaudible) sawtooth with a
149 * sufficient signal level.
150 */
151 set_attenuation(50);
152 i2s_sawtooth (200, 5, LEFT_RIGHT);
153 init_done = 1;
154 }
155}
156
157static void i2s_init(void)
158{
159 unsigned long i;
160 struct mpc5xxx_psc *psc = (struct mpc5xxx_psc*)MPC5XXX_PSC2;;
161 struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio*)MPC5XXX_GPIO;
162
163 gpio->port_config |= 0x00000070; /* PSC2 ports as Codec with MCLK */
164 psc->command = (PSC_RX_DISABLE | PSC_TX_DISABLE);
165 psc->sicr = 0x22E00000; /* 16 bit data; I2S */
166
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200167 *(vu_long *)(CONFIG_SYS_MBAR + 0x22C) = 0x805d; /* PSC2 CDM MCLK config; MCLK
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200168 * 5.617 MHz */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200169 *(vu_long *)(CONFIG_SYS_MBAR + 0x214) |= 0x00000040; /* CDM clock enable
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200170 * register */
171 psc->ccr = 0x1F03; /* 16 bit data width; 5.617MHz MCLK */
172 psc->ctur = 0x0F; /* 16 bit frame width */
173
Wolfgang Denk65766f32011-11-04 15:55:09 +0000174 for (i = 0; i < 128; i++)
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200175 psc->psc_buffer_32 = 0; /* clear tx fifo */
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200176}
177
178static int i2s_play_wave(unsigned long addr, unsigned long len)
179{
180 unsigned long i;
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200181 unsigned char *wave_file = (uchar *)addr + 44; /* quick'n dirty: skip
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200182 * wav header*/
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200183 struct mpc5xxx_psc *psc = (struct mpc5xxx_psc*)MPC5XXX_PSC2;
184
185 /*
186 * play wave file in memory; bytes/words are be swapped
187 */
188 psc->command = (PSC_RX_ENABLE | PSC_TX_ENABLE);
189
190 for(i = 0;i < (len / 4); i++) {
Wolfgang Denk65766f32011-11-04 15:55:09 +0000191 unsigned char swapped[4];
192 unsigned long *p = (unsigned long*)swapped;
193
Wolfgang Denkd0ff51b2008-07-14 15:19:07 +0200194 swapped[3] = *wave_file++;
195 swapped[2] = *wave_file++;
196 swapped[1] = *wave_file++;
197 swapped[0] = *wave_file++;
Wolfgang Denk65766f32011-11-04 15:55:09 +0000198
199 psc->psc_buffer_32 = *p;
200
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200201 while (psc->tfnum > 400) {
202 if(ctrlc())
203 return 0;
204 }
205 }
206 while (psc->tfnum > 0); /* wait for fifo empty */
207 udelay (100);
208 psc->command = (PSC_RX_DISABLE | PSC_TX_DISABLE);
209 return 0;
210}
211
212static int i2s_sawtooth(unsigned long duration, unsigned int freq,
213 unsigned int channel)
214{
215 long i,j;
216 unsigned long data;
217 struct mpc5xxx_psc *psc = (struct mpc5xxx_psc*)MPC5XXX_PSC2;
218
219 psc->command = (PSC_RX_ENABLE | PSC_TX_ENABLE);
220
221 /*
222 * Generate sawtooth. Start with middle level up to highest level. Then
223 * go to lowest level and back to middle level.
224 */
225 for(j = 0; j < ((duration * freq) / 1000); j++) {
226 for(i = 0; i <= 0x7FFF; i += (0x7FFF/(44100/(freq*4)))) {
227 data = (i & 0xFFFF);
228 /* data format: right data left data) */
229 if (channel == LEFT_RIGHT)
230 data |= (data<<16);
231 if (channel == RIGHT)
232 data = (data<<16);
233 psc->psc_buffer_32 = data;
234 while (psc->tfnum > 400);
235 }
236 for(i = 0x7FFF; i >= -0x7FFF; i -= (0xFFFF/(44100/(freq*2)))) {
237 data = (i & 0xFFFF);
238 /* data format: right data left data) */
239 if (channel == LEFT_RIGHT)
240 data |= (data<<16);
241 if (channel == RIGHT)
242 data = (data<<16);
243 psc->psc_buffer_32 = data;
244 while (psc->tfnum > 400);
245 }
246 for(i = -0x7FFF; i <= 0; i += (0x7FFF/(44100/(freq*4)))) {
247 data = (i & 0xFFFF);
248 /* data format: right data left data) */
249 if (channel == LEFT_RIGHT)
250 data |= (data<<16);
251 if (channel == RIGHT)
252 data = (data<<16);
253 psc->psc_buffer_32 = data;
254 while (psc->tfnum > 400);
255 }
256 }
257 while (psc->tfnum > 0); /* wait for fifo empty */
258 udelay (100);
259 psc->command = (PSC_RX_DISABLE | PSC_TX_DISABLE);
260
261 return 0;
262}
263
264static int i2s_squarewave(unsigned long duration, unsigned int freq,
265 unsigned int channel)
266{
267 long i,j;
268 unsigned long data;
269 struct mpc5xxx_psc *psc = (struct mpc5xxx_psc*)MPC5XXX_PSC2;
270
271 psc->command = (PSC_RX_ENABLE | PSC_TX_ENABLE);
272
273 /*
274 * Generate sqarewave. Start with high level, duty cycle 1:1.
275 */
276 for(j = 0; j < ((duration * freq) / 1000); j++) {
277 for(i = 0; i < (44100/(freq*2)); i ++) {
278 data = 0x7FFF;
279 /* data format: right data left data) */
280 if (channel == LEFT_RIGHT)
281 data |= (data<<16);
282 if (channel == RIGHT)
283 data = (data<<16);
284 psc->psc_buffer_32 = data;
285 while (psc->tfnum > 400);
286 }
287 for(i = 0; i < (44100/(freq*2)); i ++) {
288 data = 0x8000;
289 /* data format: right data left data) */
290 if (channel == LEFT_RIGHT)
291 data |= (data<<16);
292 if (channel == RIGHT)
293 data = (data<<16);
294 psc->psc_buffer_32 = data;
295 while (psc->tfnum > 400);
296 }
297 }
298 while (psc->tfnum > 0); /* wait for fifo empty */
299 udelay (100);
300 psc->command = (PSC_RX_DISABLE | PSC_TX_DISABLE);
301
302 return 0;
303}
304
Wolfgang Denk54841ab2010-06-28 22:00:46 +0200305static int cmd_sound(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200306{
307 unsigned long reg, val, duration;
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200308 char *tmp;
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200309 unsigned int freq, channel;
310 unsigned char volume;
311 int rcode = 1;
312
313#ifdef CONFIG_STK52XX_REV100
314 printf ("Revision 100 of STK52XX not supported!\n");
315 return 1;
316#endif
317 spi_init();
318 i2s_init();
319 amplifier_init();
320
321 if ((tmp = getenv ("volume")) != NULL) {
322 volume = simple_strtoul (tmp, NULL, 10);
323 } else {
324 volume = DEFAULT_VOL;
325 }
326 set_attenuation(volume);
327
328 switch (argc) {
329 case 0:
330 case 1:
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200331 return cmd_usage(cmdtp);
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200332 case 2:
333 if (strncmp(argv[1],"saw",3) == 0) {
334 printf ("Play sawtooth\n");
335 rcode = i2s_sawtooth (DEFAULT_DURATION, DEFAULT_FREQ,
336 LEFT_RIGHT);
337 return rcode;
338 } else if (strncmp(argv[1],"squ",3) == 0) {
339 printf ("Play squarewave\n");
340 rcode = i2s_squarewave (DEFAULT_DURATION, DEFAULT_FREQ,
341 LEFT_RIGHT);
342 return rcode;
343 }
344
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200345 return cmd_usage(cmdtp);
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200346 case 3:
347 if (strncmp(argv[1],"saw",3) == 0) {
348 duration = simple_strtoul(argv[2], NULL, 10);
349 printf ("Play sawtooth\n");
350 rcode = i2s_sawtooth (duration, DEFAULT_FREQ,
351 LEFT_RIGHT);
352 return rcode;
353 } else if (strncmp(argv[1],"squ",3) == 0) {
354 duration = simple_strtoul(argv[2], NULL, 10);
355 printf ("Play squarewave\n");
356 rcode = i2s_squarewave (duration, DEFAULT_FREQ,
357 LEFT_RIGHT);
358 return rcode;
359 }
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200360 return cmd_usage(cmdtp);
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200361 case 4:
362 if (strncmp(argv[1],"saw",3) == 0) {
363 duration = simple_strtoul(argv[2], NULL, 10);
364 freq = (unsigned int)simple_strtoul(argv[3], NULL, 10);
365 printf ("Play sawtooth\n");
366 rcode = i2s_sawtooth (duration, freq,
367 LEFT_RIGHT);
368 return rcode;
369 } else if (strncmp(argv[1],"squ",3) == 0) {
370 duration = simple_strtoul(argv[2], NULL, 10);
371 freq = (unsigned int)simple_strtoul(argv[3], NULL, 10);
372 printf ("Play squarewave\n");
373 rcode = i2s_squarewave (duration, freq,
374 LEFT_RIGHT);
375 return rcode;
376 } else if (strcmp(argv[1],"pcm1772") == 0) {
377 reg = simple_strtoul(argv[2], NULL, 10);
378 val = simple_strtoul(argv[3], NULL, 10);
379 printf("Set PCM1772 %lu. %lu\n", reg, val);
380 pcm1772_write_reg((uchar)reg, (uchar)val);
381 return 0;
382 }
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200383 return cmd_usage(cmdtp);
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200384 case 5:
385 if (strncmp(argv[1],"saw",3) == 0) {
386 duration = simple_strtoul(argv[2], NULL, 10);
387 freq = (unsigned int)simple_strtoul(argv[3], NULL, 10);
388 if (strncmp(argv[4],"l",1) == 0)
389 channel = LEFT;
390 else if (strncmp(argv[4],"r",1) == 0)
391 channel = RIGHT;
392 else
393 channel = LEFT_RIGHT;
394 printf ("Play squarewave\n");
395 rcode = i2s_sawtooth (duration, freq,
396 channel);
397 return rcode;
398 } else if (strncmp(argv[1],"squ",3) == 0) {
399 duration = simple_strtoul(argv[2], NULL, 10);
400 freq = (unsigned int)simple_strtoul(argv[3], NULL, 10);
401 if (strncmp(argv[4],"l",1) == 0)
402 channel = LEFT;
403 else if (strncmp(argv[4],"r",1) == 0)
404 channel = RIGHT;
405 else
406 channel = LEFT_RIGHT;
407 printf ("Play squarewave\n");
408 rcode = i2s_squarewave (duration, freq,
409 channel);
410 return rcode;
411 }
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200412 return cmd_usage(cmdtp);
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200413 }
414 printf ("Usage:\nsound cmd [arg1] [arg2] ...\n");
415 return 1;
416}
417
Wolfgang Denk54841ab2010-06-28 22:00:46 +0200418static int cmd_wav(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200419{
420 unsigned long length, addr;
421 unsigned char volume;
422 int rcode = 1;
423 char *tmp;
424
425#ifdef CONFIG_STK52XX_REV100
426 printf ("Revision 100 of STK52XX not supported!\n");
427 return 1;
428#endif
429 spi_init();
430 i2s_init();
431 amplifier_init();
432
433 switch (argc) {
434
435 case 3:
436 length = simple_strtoul(argv[2], NULL, 16);
437 addr = simple_strtoul(argv[1], NULL, 16);
438 break;
439
440 case 2:
441 if ((tmp = getenv ("filesize")) != NULL) {
442 length = simple_strtoul (tmp, NULL, 16);
443 } else {
444 puts ("No filesize provided\n");
445 return 1;
446 }
447 addr = simple_strtoul(argv[1], NULL, 16);
448
449 case 1:
450 if ((tmp = getenv ("filesize")) != NULL) {
451 length = simple_strtoul (tmp, NULL, 16);
452 } else {
453 puts ("No filesize provided\n");
454 return 1;
455 }
456 if ((tmp = getenv ("loadaddr")) != NULL) {
457 addr = simple_strtoul (tmp, NULL, 16);
458 } else {
459 puts ("No loadaddr provided\n");
460 return 1;
461 }
462 break;
463
464 default:
465 printf("Usage:\nwav <addr> <length[s]\n");
466 return 1;
467 break;
468 }
469
470 if ((tmp = getenv ("volume")) != NULL) {
471 volume = simple_strtoul (tmp, NULL, 10);
472 } else {
473 volume = DEFAULT_VOL;
474 }
475 set_attenuation(volume);
476
Wolfgang Denk9b55a252008-07-11 01:16:00 +0200477 printf("Play wave file at %lX with length %lX\n", addr, length);
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200478 rcode = i2s_play_wave(addr, length);
479
480 return rcode;
481}
482
Wolfgang Denk54841ab2010-06-28 22:00:46 +0200483static int cmd_beep(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200484{
485 unsigned char volume;
486 unsigned int channel;
487 int rcode;
488 char *tmp;
489
490#ifdef CONFIG_STK52XX_REV100
491 printf ("Revision 100 of STK52XX not supported!\n");
492 return 1;
493#endif
494 spi_init();
495 i2s_init();
496 amplifier_init();
497
498 switch (argc) {
499 case 0:
500 case 1:
501 channel = LEFT_RIGHT;
502 break;
503 case 2:
504 if (strncmp(argv[1],"l",1) == 0)
505 channel = LEFT;
506 else if (strncmp(argv[1],"r",1) == 0)
507 channel = RIGHT;
508 else
509 channel = LEFT_RIGHT;
510 break;
511 default:
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200512 return cmd_usage(cmdtp);
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200513 }
514
515 if ((tmp = getenv ("volume")) != NULL) {
516 volume = simple_strtoul (tmp, NULL, 10);
517 } else {
518 volume = DEFAULT_VOL;
519 }
520 set_attenuation(volume);
521
522 printf("Beep on ");
523 if (channel == LEFT)
524 printf ("left ");
525 else if (channel == RIGHT)
526 printf ("right ");
527 else
528 printf ("left and right ");
529 printf ("channel\n");
530
531 rcode = i2s_squarewave (DEFAULT_DURATION, DEFAULT_FREQ, channel);
532
533 return rcode;
534}
Marian Balakowicz6d3bc9b2006-08-18 19:14:46 +0200535#endif
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200536
Marian Balakowicz6d3bc9b2006-08-18 19:14:46 +0200537#if defined(CONFIG_STK52XX)
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200538void led_init(void)
539{
540 struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio *)MPC5XXX_GPIO;
541 struct mpc5xxx_gpt_0_7 *gpt = (struct mpc5xxx_gpt_0_7 *)MPC5XXX_GPT;
542
543 /* configure PSC3 for SPI and GPIO */
544 gpio->port_config &= ~(0x00000F00);
545 gpio->port_config |= 0x00000800;
546
547 gpio->simple_gpioe &= ~(0x00000F00);
548 gpio->simple_gpioe |= 0x00000F00;
549
550 gpio->simple_ddr &= ~(0x00000F00);
551 gpio->simple_ddr |= 0x00000F00;
552
553 /* configure timer 4-7 for simple GPIO output */
554 gpt->gpt4.emsr |= 0x00000024;
555 gpt->gpt5.emsr |= 0x00000024;
556 gpt->gpt6.emsr |= 0x00000024;
557 gpt->gpt7.emsr |= 0x00000024;
558
Martin Krause0fc0f912007-10-22 16:40:06 +0200559#ifndef CONFIG_TQM5200S
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200560 /* enable SM501 GPIO control (in both power modes) */
561 *(vu_long *) (SM501_MMIO_BASE+SM501_POWER_MODE0_GATE) |=
562 POWER_MODE_GATE_GPIO_PWM_I2C;
563 *(vu_long *) (SM501_MMIO_BASE+SM501_POWER_MODE1_GATE) |=
564 POWER_MODE_GATE_GPIO_PWM_I2C;
565
566 /* configure SM501 gpio pins 24-27 as output */
567 *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_CTRL_LOW) &= ~(0xF << 24);
568 *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_DIR_LOW) |= (0xF << 24);
569
570 /* configure SM501 gpio pins 48-51 as output */
571 *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_DIR_HIGH) |= (0xF << 16);
Martin Krause0fc0f912007-10-22 16:40:06 +0200572#endif /* !CONFIG_TQM5200S */
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200573}
574
575/*
576 * return 1 if led number unknown
577 * return 0 else
578 */
Wolfgang Denk54841ab2010-06-28 22:00:46 +0200579int do_led(char * const argv[])
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200580{
581 struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio *)MPC5XXX_GPIO;
582 struct mpc5xxx_gpt_0_7 *gpt = (struct mpc5xxx_gpt_0_7 *)MPC5XXX_GPT;
583
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200584 switch (simple_strtoul(argv[2], NULL, 10)) {
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200585
586 case 0:
587 if (strcmp (argv[3], "on") == 0) {
588 gpio->simple_dvo |= (1 << 8);
589 } else {
590 gpio->simple_dvo &= ~(1 << 8);
591 }
592 break;
593
594 case 1:
595 if (strcmp (argv[3], "on") == 0) {
596 gpio->simple_dvo |= (1 << 9);
597 } else {
598 gpio->simple_dvo &= ~(1 << 9);
599 }
600 break;
601
602 case 2:
603 if (strcmp (argv[3], "on") == 0) {
604 gpio->simple_dvo |= (1 << 10);
605 } else {
606 gpio->simple_dvo &= ~(1 << 10);
607 }
608 break;
609
610 case 3:
611 if (strcmp (argv[3], "on") == 0) {
612 gpio->simple_dvo |= (1 << 11);
613 } else {
614 gpio->simple_dvo &= ~(1 << 11);
615 }
616 break;
617
618 case 4:
619 if (strcmp (argv[3], "on") == 0) {
620 gpt->gpt4.emsr |= (1 << 4);
621 } else {
622 gpt->gpt4.emsr &= ~(1 << 4);
623 }
624 break;
625
626 case 5:
627 if (strcmp (argv[3], "on") == 0) {
628 gpt->gpt5.emsr |= (1 << 4);
629 } else {
630 gpt->gpt5.emsr &= ~(1 << 4);
631 }
632 break;
633
634 case 6:
635 if (strcmp (argv[3], "on") == 0) {
636 gpt->gpt6.emsr |= (1 << 4);
637 } else {
638 gpt->gpt6.emsr &= ~(1 << 4);
639 }
640 break;
641
642 case 7:
643 if (strcmp (argv[3], "on") == 0) {
644 gpt->gpt7.emsr |= (1 << 4);
645 } else {
646 gpt->gpt7.emsr &= ~(1 << 4);
647 }
648 break;
Martin Krause0fc0f912007-10-22 16:40:06 +0200649#ifndef CONFIG_TQM5200S
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200650 case 24:
651 if (strcmp (argv[3], "on") == 0) {
652 *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_LOW) |=
653 (0x1 << 24);
654 } else {
655 *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_LOW) &=
656 ~(0x1 << 24);
657 }
658 break;
659
660 case 25:
661 if (strcmp (argv[3], "on") == 0) {
662 *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_LOW) |=
663 (0x1 << 25);
664 } else {
665 *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_LOW) &=
666 ~(0x1 << 25);
667 }
668 break;
669
670 case 26:
671 if (strcmp (argv[3], "on") == 0) {
672 *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_LOW) |=
673 (0x1 << 26);
674 } else {
675 *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_LOW) &=
676 ~(0x1 << 26);
677 }
678 break;
679
680 case 27:
681 if (strcmp (argv[3], "on") == 0) {
682 *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_LOW) |=
683 (0x1 << 27);
684 } else {
685 *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_LOW) &=
686 ~(0x1 << 27);
687 }
688 break;
689
690 case 48:
691 if (strcmp (argv[3], "on") == 0) {
692 *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) |=
693 (0x1 << 16);
694 } else {
695 *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) &=
696 ~(0x1 << 16);
697 }
698 break;
699
700 case 49:
701 if (strcmp (argv[3], "on") == 0) {
702 *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) |=
703 (0x1 << 17);
704 } else {
705 *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) &=
706 ~(0x1 << 17);
707 }
708 break;
709
710 case 50:
711 if (strcmp (argv[3], "on") == 0) {
712 *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) |=
713 (0x1 << 18);
714 } else {
715 *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) &=
716 ~(0x1 << 18);
717 }
718 break;
719
720 case 51:
721 if (strcmp (argv[3], "on") == 0) {
722 *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) |=
723 (0x1 << 19);
724 } else {
725 *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) &=
726 ~(0x1 << 19);
727 }
728 break;
Martin Krause0fc0f912007-10-22 16:40:06 +0200729#endif /* !CONFIG_TQM5200S */
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200730 default:
731 printf ("%s: invalid led number %s\n", __FUNCTION__, argv[2]);
732 return 1;
733 }
734
735 return 0;
736}
Marian Balakowicz6d3bc9b2006-08-18 19:14:46 +0200737#endif
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200738
Marian Balakowicz6d3bc9b2006-08-18 19:14:46 +0200739#if defined(CONFIG_STK52XX) || defined(CONFIG_FO300)
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200740/*
741 * return 1 on CAN initialization failure
742 * return 0 if no failure
743 */
744int can_init(void)
745{
746 static int init_done = 0;
747 int i;
748 struct mpc5xxx_mscan *can1 =
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200749 (struct mpc5xxx_mscan *)(CONFIG_SYS_MBAR + 0x0900);
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200750 struct mpc5xxx_mscan *can2 =
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200751 (struct mpc5xxx_mscan *)(CONFIG_SYS_MBAR + 0x0980);
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200752
753 /* GPIO configuration of the CAN pins is done in TQM5200.h */
754
755 if (!init_done) {
756 /* init CAN 1 */
757 can1->canctl1 |= 0x80; /* CAN enable */
758 udelay(100);
759
760 i = 0;
761 can1->canctl0 |= 0x02; /* sleep mode */
762 /* wait until sleep mode reached */
763 while (!(can1->canctl1 & 0x02)) {
764 udelay(10);
765 i++;
766 if (i == 10) {
767 printf ("%s: CAN1 initialize error, "
768 "can not enter sleep mode!\n",
769 __FUNCTION__);
770 return 1;
771 }
772 }
773 i = 0;
774 can1->canctl0 = 0x01; /* enter init mode */
775 /* wait until init mode reached */
776 while (!(can1->canctl1 & 0x01)) {
777 udelay(10);
778 i++;
779 if (i == 10) {
780 printf ("%s: CAN1 initialize error, "
781 "can not enter init mode!\n",
782 __FUNCTION__);
783 return 1;
784 }
785 }
786 can1->canctl1 = 0x80;
787 can1->canctl1 |= 0x40;
788 can1->canbtr0 = 0x0F;
789 can1->canbtr1 = 0x7F;
790 can1->canidac &= ~(0x30);
791 can1->canidar1 = 0x00;
792 can1->canidar3 = 0x00;
793 can1->canidar5 = 0x00;
794 can1->canidar7 = 0x00;
795 can1->canidmr0 = 0xFF;
796 can1->canidmr1 = 0xFF;
797 can1->canidmr2 = 0xFF;
798 can1->canidmr3 = 0xFF;
799 can1->canidmr4 = 0xFF;
800 can1->canidmr5 = 0xFF;
801 can1->canidmr6 = 0xFF;
802 can1->canidmr7 = 0xFF;
803
804 i = 0;
805 can1->canctl0 &= ~(0x01); /* leave init mode */
806 can1->canctl0 &= ~(0x02);
807 /* wait until init and sleep mode left */
808 while ((can1->canctl1 & 0x01) || (can1->canctl1 & 0x02)) {
809 udelay(10);
810 i++;
811 if (i == 10) {
812 printf ("%s: CAN1 initialize error, "
813 "can not leave init/sleep mode!\n",
814 __FUNCTION__);
815 return 1;
816 }
817 }
818
819 /* init CAN 2 */
820 can2->canctl1 |= 0x80; /* CAN enable */
821 udelay(100);
822
823 i = 0;
824 can2->canctl0 |= 0x02; /* sleep mode */
825 /* wait until sleep mode reached */
826 while (!(can2->canctl1 & 0x02)) {
827 udelay(10);
828 i++;
829 if (i == 10) {
830 printf ("%s: CAN2 initialize error, "
831 "can not enter sleep mode!\n",
832 __FUNCTION__);
833 return 1;
834 }
835 }
836 i = 0;
837 can2->canctl0 = 0x01; /* enter init mode */
838 /* wait until init mode reached */
839 while (!(can2->canctl1 & 0x01)) {
840 udelay(10);
841 i++;
842 if (i == 10) {
843 printf ("%s: CAN2 initialize error, "
844 "can not enter init mode!\n",
845 __FUNCTION__);
846 return 1;
847 }
848 }
849 can2->canctl1 = 0x80;
850 can2->canctl1 |= 0x40;
851 can2->canbtr0 = 0x0F;
852 can2->canbtr1 = 0x7F;
853 can2->canidac &= ~(0x30);
854 can2->canidar1 = 0x00;
855 can2->canidar3 = 0x00;
856 can2->canidar5 = 0x00;
857 can2->canidar7 = 0x00;
858 can2->canidmr0 = 0xFF;
859 can2->canidmr1 = 0xFF;
860 can2->canidmr2 = 0xFF;
861 can2->canidmr3 = 0xFF;
862 can2->canidmr4 = 0xFF;
863 can2->canidmr5 = 0xFF;
864 can2->canidmr6 = 0xFF;
865 can2->canidmr7 = 0xFF;
866 can2->canctl0 &= ~(0x01); /* leave init mode */
867 can2->canctl0 &= ~(0x02);
868
869 i = 0;
870 /* wait until init mode left */
871 while ((can2->canctl1 & 0x01) || (can2->canctl1 & 0x02)) {
872 udelay(10);
873 i++;
874 if (i == 10) {
875 printf ("%s: CAN2 initialize error, "
876 "can not leave init/sleep mode!\n",
877 __FUNCTION__);
878 return 1;
879 }
880 }
881 init_done = 1;
882 }
883 return 0;
884}
885
886/*
887 * return 1 on CAN failure
888 * return 0 if no failure
889 */
Wolfgang Denk54841ab2010-06-28 22:00:46 +0200890int do_can(char * const argv[])
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200891{
892 int i;
893 struct mpc5xxx_mscan *can1 =
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200894 (struct mpc5xxx_mscan *)(CONFIG_SYS_MBAR + 0x0900);
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200895 struct mpc5xxx_mscan *can2 =
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200896 (struct mpc5xxx_mscan *)(CONFIG_SYS_MBAR + 0x0980);
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200897
898 /* send a message on CAN1 */
899 can1->cantbsel = 0x01;
900 can1->cantxfg.idr[0] = 0x55;
901 can1->cantxfg.idr[1] = 0x00;
902 can1->cantxfg.idr[1] &= ~0x8;
903 can1->cantxfg.idr[1] &= ~0x10;
904 can1->cantxfg.dsr[0] = 0xCC;
905 can1->cantxfg.dlr = 1;
906 can1->cantxfg.tbpr = 0;
907 can1->cantflg = 0x01;
908
909 i = 0;
910 while ((can1->cantflg & 0x01) == 0) {
911 i++;
912 if (i == 10) {
913 printf ("%s: CAN1 send timeout, "
914 "can not send message!\n",
915 __FUNCTION__);
916 return 1;
917 }
918 udelay(1000);
919 }
920 udelay(1000);
921
922 i = 0;
923 while (!(can2->canrflg & 0x01)) {
924 i++;
925 if (i == 10) {
926 printf ("%s: CAN2 receive timeout, "
927 "no message received!\n",
928 __FUNCTION__);
929 return 1;
930 }
931 udelay(1000);
932 }
933
934 if (can2->canrxfg.dsr[0] != 0xCC) {
935 printf ("%s: CAN2 receive error, "
936 "data mismatch!\n",
937 __FUNCTION__);
938 return 1;
939 }
940
941 /* send a message on CAN2 */
942 can2->cantbsel = 0x01;
943 can2->cantxfg.idr[0] = 0x55;
944 can2->cantxfg.idr[1] = 0x00;
945 can2->cantxfg.idr[1] &= ~0x8;
946 can2->cantxfg.idr[1] &= ~0x10;
947 can2->cantxfg.dsr[0] = 0xCC;
948 can2->cantxfg.dlr = 1;
949 can2->cantxfg.tbpr = 0;
950 can2->cantflg = 0x01;
951
952 i = 0;
953 while ((can2->cantflg & 0x01) == 0) {
954 i++;
955 if (i == 10) {
956 printf ("%s: CAN2 send error, "
957 "can not send message!\n",
958 __FUNCTION__);
959 return 1;
960 }
961 udelay(1000);
962 }
963 udelay(1000);
964
965 i = 0;
966 while (!(can1->canrflg & 0x01)) {
967 i++;
968 if (i == 10) {
969 printf ("%s: CAN1 receive timeout, "
970 "no message received!\n",
971 __FUNCTION__);
972 return 1;
973 }
974 udelay(1000);
975 }
976
977 if (can1->canrxfg.dsr[0] != 0xCC) {
978 printf ("%s: CAN1 receive error 0x%02x\n",
979 __FUNCTION__, (can1->canrxfg.dsr[0]));
980 return 1;
981 }
982
983 return 0;
984}
985
986/*
987 * return 1 if rs232 port unknown
988 * return 2 on txd/rxd failure (only rs232 2)
989 * return 3 on rts/cts failure
990 * return 0 if no failure
991 */
Wolfgang Denk54841ab2010-06-28 22:00:46 +0200992int do_rs232(char * const argv[])
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200993{
994 int error_status = 0;
995 struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio *)MPC5XXX_GPIO;
996 struct mpc5xxx_psc *psc1 = (struct mpc5xxx_psc *)MPC5XXX_PSC1;
997
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200998 switch (simple_strtoul(argv[2], NULL, 10)) {
Wolfgang Denk6617aae2005-08-19 00:46:54 +0200999
1000 case 1:
1001 /* check RTS <-> CTS loop */
1002 /* set rts to 0 */
1003 psc1->op1 |= 0x01;
1004
1005 /* wait some time before requesting status */
1006 udelay(10);
1007
1008 /* check status at cts */
1009 if ((psc1->ip & 0x01) != 0) {
1010 error_status = 3;
1011 printf ("%s: failure at rs232_1, cts status is %d "
1012 "(should be 0)\n",
1013 __FUNCTION__, (psc1->ip & 0x01));
1014 }
1015
1016 /* set rts to 1 */
1017 psc1->op0 |= 0x01;
1018
1019 /* wait some time before requesting status */
1020 udelay(10);
1021
1022 /* check status at cts */
1023 if ((psc1->ip & 0x01) != 1) {
1024 error_status = 3;
1025 printf ("%s: failure at rs232_1, cts status is %d "
1026 "(should be 1)\n",
1027 __FUNCTION__, (psc1->ip & 0x01));
1028 }
1029
1030 break;
1031
1032 case 2:
1033 /* set PSC3_0, PSC3_2 as output and PSC3_1, PSC3_3 as input */
1034 gpio->simple_ddr &= ~(0x00000F00);
1035 gpio->simple_ddr |= 0x00000500;
1036
1037 /* check TXD <-> RXD loop */
1038 /* set TXD to 1 */
1039 gpio->simple_dvo |= (1 << 8);
1040
1041 /* wait some time before requesting status */
1042 udelay(10);
1043
1044 if ((gpio->simple_ival & 0x00000200) != 0x00000200) {
1045 error_status = 2;
1046 printf ("%s: failure at rs232_2, rxd status is %d "
1047 "(should be 1)\n",
1048 __FUNCTION__,
1049 (gpio->simple_ival & 0x00000200) >> 9);
1050 }
1051
1052 /* set TXD to 0 */
1053 gpio->simple_dvo &= ~(1 << 8);
1054
1055 /* wait some time before requesting status */
1056 udelay(10);
1057
1058 if ((gpio->simple_ival & 0x00000200) != 0x00000000) {
1059 error_status = 2;
1060 printf ("%s: failure at rs232_2, rxd status is %d "
1061 "(should be 0)\n",
1062 __FUNCTION__,
1063 (gpio->simple_ival & 0x00000200) >> 9);
1064 }
1065
1066 /* check RTS <-> CTS loop */
1067 /* set RTS to 1 */
1068 gpio->simple_dvo |= (1 << 10);
1069
1070 /* wait some time before requesting status */
1071 udelay(10);
1072
1073 if ((gpio->simple_ival & 0x00000800) != 0x00000800) {
1074 error_status = 3;
1075 printf ("%s: failure at rs232_2, cts status is %d "
1076 "(should be 1)\n",
1077 __FUNCTION__,
1078 (gpio->simple_ival & 0x00000800) >> 11);
1079 }
1080
1081 /* set RTS to 0 */
1082 gpio->simple_dvo &= ~(1 << 10);
1083
1084 /* wait some time before requesting status */
1085 udelay(10);
1086
1087 if ((gpio->simple_ival & 0x00000800) != 0x00000000) {
1088 error_status = 3;
1089 printf ("%s: failure at rs232_2, cts status is %d "
1090 "(should be 0)\n",
1091 __FUNCTION__,
1092 (gpio->simple_ival & 0x00000800) >> 11);
1093 }
1094
1095 /* set PSC3_0, PSC3_1, PSC3_2 and PSC3_3 as output */
1096 gpio->simple_ddr &= ~(0x00000F00);
1097 gpio->simple_ddr |= 0x00000F00;
1098 break;
1099
1100 default:
1101 printf ("%s: invalid rs232 number %s\n", __FUNCTION__, argv[2]);
1102 error_status = 1;
1103 break;
1104 }
1105
1106 return error_status;
1107}
1108
Martin Krause0fc0f912007-10-22 16:40:06 +02001109#if !defined(CONFIG_FO300) && !defined(CONFIG_TQM5200S)
Wolfgang Denk6617aae2005-08-19 00:46:54 +02001110static void sm501_backlight (unsigned int state)
1111{
1112 if (state == BL_ON) {
1113 *(vu_long *)(SM501_MMIO_BASE+SM501_PANEL_DISPLAY_CONTROL) |=
1114 (1 << 26) | (1 << 27);
1115 } else if (state == BL_OFF)
1116 *(vu_long *)(SM501_MMIO_BASE+SM501_PANEL_DISPLAY_CONTROL) &=
1117 ~((1 << 26) | (1 << 27));
1118}
Martin Krause0fc0f912007-10-22 16:40:06 +02001119#endif /* !CONFIG_FO300 & !CONFIG_TQM5200S */
Wolfgang Denk6617aae2005-08-19 00:46:54 +02001120
Wolfgang Denk54841ab2010-06-28 22:00:46 +02001121int cmd_fkt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Wolfgang Denk6617aae2005-08-19 00:46:54 +02001122{
1123 int rcode;
1124
1125#ifdef CONFIG_STK52XX_REV100
1126 printf ("Revision 100 of STK52XX not supported!\n");
1127 return 1;
1128#endif
Marian Balakowicz6d3bc9b2006-08-18 19:14:46 +02001129#if defined(CONFIG_STK52XX)
Wolfgang Denk6617aae2005-08-19 00:46:54 +02001130 led_init();
Marian Balakowicz6d3bc9b2006-08-18 19:14:46 +02001131#endif
Wolfgang Denk6617aae2005-08-19 00:46:54 +02001132 can_init();
1133
1134 switch (argc) {
1135
1136 case 0:
1137 case 1:
1138 break;
1139
1140 case 2:
1141 if (strncmp (argv[1], "can", 3) == 0) {
1142 rcode = do_can (argv);
1143 if (rcode == 0)
1144 printf ("OK\n");
1145 else
1146 printf ("Error\n");
1147 return rcode;
1148 }
1149 break;
1150
1151 case 3:
1152 if (strncmp (argv[1], "rs232", 3) == 0) {
1153 rcode = do_rs232 (argv);
1154 if (rcode == 0)
1155 printf ("OK\n");
1156 else
1157 printf ("Error\n");
1158 return rcode;
Martin Krause0fc0f912007-10-22 16:40:06 +02001159#if !defined(CONFIG_FO300) && !defined(CONFIG_TQM5200S)
Wolfgang Denk6617aae2005-08-19 00:46:54 +02001160 } else if (strncmp (argv[1], "backlight", 4) == 0) {
1161 if (strncmp (argv[2], "on", 2) == 0) {
1162 sm501_backlight (BL_ON);
1163 return 0;
1164 }
1165 else if (strncmp (argv[2], "off", 3) == 0) {
1166 sm501_backlight (BL_OFF);
1167 return 0;
1168 }
Martin Krause0fc0f912007-10-22 16:40:06 +02001169#endif /* !CONFIG_FO300 & !CONFIG_TQM5200S */
Wolfgang Denk6617aae2005-08-19 00:46:54 +02001170 }
1171 break;
1172
Marian Balakowicz6d3bc9b2006-08-18 19:14:46 +02001173#if defined(CONFIG_STK52XX)
Wolfgang Denk6617aae2005-08-19 00:46:54 +02001174 case 4:
1175 if (strcmp (argv[1], "led") == 0) {
1176 return (do_led (argv));
1177 }
1178 break;
Marian Balakowicz6d3bc9b2006-08-18 19:14:46 +02001179#endif
Wolfgang Denk6617aae2005-08-19 00:46:54 +02001180
1181 default:
1182 break;
1183 }
1184
1185 printf ("Usage:\nfkt cmd [arg1] [arg2] ...\n");
1186 return 1;
1187}
1188
1189
1190U_BOOT_CMD(
1191 sound , 5, 1, cmd_sound,
Peter Tyser2fb26042009-01-27 18:03:12 -06001192 "Sound sub-system",
Wolfgang Denk6617aae2005-08-19 00:46:54 +02001193 "saw [duration] [freq] [channel]\n"
1194 " - generate sawtooth for 'duration' ms with frequency 'freq'\n"
1195 " on left \"l\" or right \"r\" channel\n"
1196 "sound square [duration] [freq] [channel]\n"
1197 " - generate squarewave for 'duration' ms with frequency 'freq'\n"
1198 " on left \"l\" or right \"r\" channel\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +02001199 "pcm1772 reg val"
Wolfgang Denk6617aae2005-08-19 00:46:54 +02001200);
1201
1202U_BOOT_CMD(
1203 wav , 3, 1, cmd_wav,
Peter Tyser2fb26042009-01-27 18:03:12 -06001204 "play wav file",
Wolfgang Denk6617aae2005-08-19 00:46:54 +02001205 "[addr] [bytes]\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +02001206 " - play wav file at address 'addr' with length 'bytes'"
Wolfgang Denk6617aae2005-08-19 00:46:54 +02001207);
1208
1209U_BOOT_CMD(
1210 beep , 2, 1, cmd_beep,
Peter Tyser2fb26042009-01-27 18:03:12 -06001211 "play short beep",
Wolfgang Denk6617aae2005-08-19 00:46:54 +02001212 "[channel]\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +02001213 " - play short beep on \"l\"eft or \"r\"ight channel"
Wolfgang Denk6617aae2005-08-19 00:46:54 +02001214);
Marian Balakowicz6d3bc9b2006-08-18 19:14:46 +02001215#endif /* CONFIG_STK52XX || CONFIG_FO300 */
Wolfgang Denk6617aae2005-08-19 00:46:54 +02001216
Marian Balakowicz6d3bc9b2006-08-18 19:14:46 +02001217#if defined(CONFIG_STK52XX)
Wolfgang Denk6617aae2005-08-19 00:46:54 +02001218U_BOOT_CMD(
1219 fkt , 4, 1, cmd_fkt,
Peter Tyser2fb26042009-01-27 18:03:12 -06001220 "Function test routines",
Wolfgang Denk6617aae2005-08-19 00:46:54 +02001221 "led number on/off\n"
Wolfgang Denk45a212c2006-07-19 17:52:30 +02001222 " - 'number's like printed on STK52XX board\n"
Wolfgang Denk6617aae2005-08-19 00:46:54 +02001223 "fkt can\n"
1224 " - loopback plug for X83 required\n"
1225 "fkt rs232 number\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +02001226 " - loopback plug(s) for X2 required"
Martin Krause0fc0f912007-10-22 16:40:06 +02001227#ifndef CONFIG_TQM5200S
Wolfgang Denka89c33d2009-05-24 17:06:54 +02001228 "\n"
Wolfgang Denk6617aae2005-08-19 00:46:54 +02001229 "fkt backlight on/off\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +02001230 " - switch backlight on or off"
Martin Krause0fc0f912007-10-22 16:40:06 +02001231#endif /* !CONFIG_TQM5200S */
Wolfgang Denk6617aae2005-08-19 00:46:54 +02001232);
Marian Balakowicz6d3bc9b2006-08-18 19:14:46 +02001233#elif defined(CONFIG_FO300)
1234U_BOOT_CMD(
1235 fkt , 3, 1, cmd_fkt,
Peter Tyser2fb26042009-01-27 18:03:12 -06001236 "Function test routines",
Marian Balakowicz6d3bc9b2006-08-18 19:14:46 +02001237 "fkt can\n"
1238 " - loopback plug for X16/X29 required\n"
1239 "fkt rs232 number\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +02001240 " - loopback plug(s) for X21/X22 required"
Marian Balakowicz6d3bc9b2006-08-18 19:14:46 +02001241);
1242#endif
Jon Loeligerd39b5742007-07-10 10:48:22 -05001243#endif