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