cmd_stk52xx.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242
  1. /*
  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. * STK52XX specific functions
  25. */
  26. /*#define DEBUG*/
  27. #include <common.h>
  28. #include <command.h>
  29. #if defined(CONFIG_CMD_BSP)
  30. #if defined(CONFIG_STK52XX) || defined(CONFIG_FO300)
  31. #define DEFAULT_VOL 45
  32. #define DEFAULT_FREQ 500
  33. #define DEFAULT_DURATION 200
  34. #define LEFT 1
  35. #define RIGHT 2
  36. #define LEFT_RIGHT 3
  37. #define BL_OFF 0
  38. #define BL_ON 1
  39. #define SM501_GPIO_CTRL_LOW 0x00000008UL
  40. #define SM501_GPIO_CTRL_HIGH 0x0000000CUL
  41. #define SM501_POWER_MODE0_GATE 0x00000040UL
  42. #define SM501_POWER_MODE1_GATE 0x00000048UL
  43. #define POWER_MODE_GATE_GPIO_PWM_I2C 0x00000040UL
  44. #define SM501_GPIO_DATA_LOW 0x00010000UL
  45. #define SM501_GPIO_DATA_HIGH 0x00010004UL
  46. #define SM501_GPIO_DATA_DIR_LOW 0x00010008UL
  47. #define SM501_GPIO_DATA_DIR_HIGH 0x0001000CUL
  48. #define SM501_PANEL_DISPLAY_CONTROL 0x00080000UL
  49. static int i2s_squarewave(unsigned long duration, unsigned int freq,
  50. unsigned int channel);
  51. static int i2s_sawtooth(unsigned long duration, unsigned int freq,
  52. unsigned int channel);
  53. static void spi_init(void);
  54. static int spi_transmit(unsigned char data);
  55. static void pcm1772_write_reg(unsigned char addr, unsigned char data);
  56. static void set_attenuation(unsigned char attenuation);
  57. static void spi_init(void)
  58. {
  59. struct mpc5xxx_spi *spi = (struct mpc5xxx_spi*)MPC5XXX_SPI;
  60. struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio*)MPC5XXX_GPIO;
  61. /* PSC3 as SPI and GPIOs */
  62. gpio->port_config &= 0xFFFFF0FF;
  63. gpio->port_config |= 0x00000800;
  64. /*
  65. * Its important to use the correct order when initializing the
  66. * registers
  67. */
  68. spi->ddr = 0x0F; /* set all SPI pins as output */
  69. spi->pdr = 0x08; /* set SS high */
  70. spi->cr1 = 0x50; /* SPI is master, SS is general purpose output */
  71. spi->cr2 = 0x00; /* normal operation */
  72. spi->brr = 0xFF; /* baud rate: IPB clock / 2048 */
  73. }
  74. static int spi_transmit(unsigned char data)
  75. {
  76. int dummy;
  77. struct mpc5xxx_spi *spi = (struct mpc5xxx_spi*)MPC5XXX_SPI;
  78. spi->dr = data;
  79. /* wait for SPI transmission completed */
  80. while(!(spi->sr & 0x80))
  81. {
  82. if (spi->sr & 0x40) /* if write collision occured */
  83. {
  84. /* do dummy read to clear status register */
  85. dummy = spi->dr;
  86. printf ("SPI write collision\n");
  87. return -1;
  88. }
  89. }
  90. return (spi->dr);
  91. }
  92. static void pcm1772_write_reg(unsigned char addr, unsigned char data)
  93. {
  94. struct mpc5xxx_spi *spi = (struct mpc5xxx_spi*)MPC5XXX_SPI;
  95. spi->pdr = 0x00; /* Set SS low */
  96. spi_transmit(addr);
  97. spi_transmit(data);
  98. /* wait some time to meet MS# hold time of PCM1772 */
  99. udelay (1);
  100. spi->pdr = 0x08; /* set SS high */
  101. }
  102. static void set_attenuation(unsigned char attenuation)
  103. {
  104. pcm1772_write_reg(0x01, attenuation); /* left channel */
  105. debug ("PCM1772 attenuation left set to %d.\n", attenuation);
  106. pcm1772_write_reg(0x02, attenuation); /* right channel */
  107. debug ("PCM1772 attenuation right set to %d.\n", attenuation);
  108. }
  109. void amplifier_init(void)
  110. {
  111. static int init_done = 0;
  112. int i;
  113. struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio*)MPC5XXX_GPIO;
  114. /* Do this only once, because of the long time delay */
  115. if (!init_done) {
  116. /* configure PCM1772 audio format as I2S */
  117. pcm1772_write_reg(0x03, 0x01);
  118. /* enable audio amplifier */
  119. gpio->sint_gpioe |= 0x02; /* PSC3_5 as GPIO */
  120. gpio->sint_ode &= ~0x02; /* PSC3_5 is not open Drain */
  121. gpio->sint_dvo &= ~0x02; /* PSC3_5 is LOW */
  122. gpio->sint_ddr |= 0x02; /* PSC3_5 as output */
  123. /*
  124. * wait some time to allow amplifier to recover from shutdown
  125. * mode.
  126. */
  127. for(i = 0; i < 350; i++)
  128. udelay(1000);
  129. /*
  130. * The used amplifier (LM4867) has a so called "pop and click"
  131. * elmination filter. The input signal of the amplifier must
  132. * exceed a certain level once after power up to activate the
  133. * generation of the output signal. This is achieved by
  134. * sending a low frequent (nearly inaudible) sawtooth with a
  135. * sufficient signal level.
  136. */
  137. set_attenuation(50);
  138. i2s_sawtooth (200, 5, LEFT_RIGHT);
  139. init_done = 1;
  140. }
  141. }
  142. static void i2s_init(void)
  143. {
  144. unsigned long i;
  145. struct mpc5xxx_psc *psc = (struct mpc5xxx_psc*)MPC5XXX_PSC2;;
  146. struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio*)MPC5XXX_GPIO;
  147. gpio->port_config |= 0x00000070; /* PSC2 ports as Codec with MCLK */
  148. psc->command = (PSC_RX_DISABLE | PSC_TX_DISABLE);
  149. psc->sicr = 0x22E00000; /* 16 bit data; I2S */
  150. *(vu_long *)(CONFIG_SYS_MBAR + 0x22C) = 0x805d; /* PSC2 CDM MCLK config; MCLK
  151. * 5.617 MHz */
  152. *(vu_long *)(CONFIG_SYS_MBAR + 0x214) |= 0x00000040; /* CDM clock enable
  153. * register */
  154. psc->ccr = 0x1F03; /* 16 bit data width; 5.617MHz MCLK */
  155. psc->ctur = 0x0F; /* 16 bit frame width */
  156. for(i=0;i<128;i++)
  157. {
  158. psc->psc_buffer_32 = 0; /* clear tx fifo */
  159. }
  160. }
  161. static int i2s_play_wave(unsigned long addr, unsigned long len)
  162. {
  163. unsigned long i;
  164. unsigned char *wave_file = (uchar *)addr + 44; /* quick'n dirty: skip
  165. * wav header*/
  166. unsigned char swapped[4];
  167. struct mpc5xxx_psc *psc = (struct mpc5xxx_psc*)MPC5XXX_PSC2;
  168. /*
  169. * play wave file in memory; bytes/words are be swapped
  170. */
  171. psc->command = (PSC_RX_ENABLE | PSC_TX_ENABLE);
  172. for(i = 0;i < (len / 4); i++) {
  173. swapped[3] = *wave_file++;
  174. swapped[2] = *wave_file++;
  175. swapped[1] = *wave_file++;
  176. swapped[0] = *wave_file++;
  177. psc->psc_buffer_32 = *((unsigned long*)swapped);
  178. while (psc->tfnum > 400) {
  179. if(ctrlc())
  180. return 0;
  181. }
  182. }
  183. while (psc->tfnum > 0); /* wait for fifo empty */
  184. udelay (100);
  185. psc->command = (PSC_RX_DISABLE | PSC_TX_DISABLE);
  186. return 0;
  187. }
  188. static int i2s_sawtooth(unsigned long duration, unsigned int freq,
  189. unsigned int channel)
  190. {
  191. long i,j;
  192. unsigned long data;
  193. struct mpc5xxx_psc *psc = (struct mpc5xxx_psc*)MPC5XXX_PSC2;
  194. psc->command = (PSC_RX_ENABLE | PSC_TX_ENABLE);
  195. /*
  196. * Generate sawtooth. Start with middle level up to highest level. Then
  197. * go to lowest level and back to middle level.
  198. */
  199. for(j = 0; j < ((duration * freq) / 1000); j++) {
  200. for(i = 0; i <= 0x7FFF; i += (0x7FFF/(44100/(freq*4)))) {
  201. data = (i & 0xFFFF);
  202. /* data format: right data left data) */
  203. if (channel == LEFT_RIGHT)
  204. data |= (data<<16);
  205. if (channel == RIGHT)
  206. data = (data<<16);
  207. psc->psc_buffer_32 = data;
  208. while (psc->tfnum > 400);
  209. }
  210. for(i = 0x7FFF; i >= -0x7FFF; i -= (0xFFFF/(44100/(freq*2)))) {
  211. data = (i & 0xFFFF);
  212. /* data format: right data left data) */
  213. if (channel == LEFT_RIGHT)
  214. data |= (data<<16);
  215. if (channel == RIGHT)
  216. data = (data<<16);
  217. psc->psc_buffer_32 = data;
  218. while (psc->tfnum > 400);
  219. }
  220. for(i = -0x7FFF; i <= 0; i += (0x7FFF/(44100/(freq*4)))) {
  221. data = (i & 0xFFFF);
  222. /* data format: right data left data) */
  223. if (channel == LEFT_RIGHT)
  224. data |= (data<<16);
  225. if (channel == RIGHT)
  226. data = (data<<16);
  227. psc->psc_buffer_32 = data;
  228. while (psc->tfnum > 400);
  229. }
  230. }
  231. while (psc->tfnum > 0); /* wait for fifo empty */
  232. udelay (100);
  233. psc->command = (PSC_RX_DISABLE | PSC_TX_DISABLE);
  234. return 0;
  235. }
  236. static int i2s_squarewave(unsigned long duration, unsigned int freq,
  237. unsigned int channel)
  238. {
  239. long i,j;
  240. unsigned long data;
  241. struct mpc5xxx_psc *psc = (struct mpc5xxx_psc*)MPC5XXX_PSC2;
  242. psc->command = (PSC_RX_ENABLE | PSC_TX_ENABLE);
  243. /*
  244. * Generate sqarewave. Start with high level, duty cycle 1:1.
  245. */
  246. for(j = 0; j < ((duration * freq) / 1000); j++) {
  247. for(i = 0; i < (44100/(freq*2)); i ++) {
  248. data = 0x7FFF;
  249. /* data format: right data left data) */
  250. if (channel == LEFT_RIGHT)
  251. data |= (data<<16);
  252. if (channel == RIGHT)
  253. data = (data<<16);
  254. psc->psc_buffer_32 = data;
  255. while (psc->tfnum > 400);
  256. }
  257. for(i = 0; i < (44100/(freq*2)); i ++) {
  258. data = 0x8000;
  259. /* data format: right data left data) */
  260. if (channel == LEFT_RIGHT)
  261. data |= (data<<16);
  262. if (channel == RIGHT)
  263. data = (data<<16);
  264. psc->psc_buffer_32 = data;
  265. while (psc->tfnum > 400);
  266. }
  267. }
  268. while (psc->tfnum > 0); /* wait for fifo empty */
  269. udelay (100);
  270. psc->command = (PSC_RX_DISABLE | PSC_TX_DISABLE);
  271. return 0;
  272. }
  273. static int cmd_sound(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  274. {
  275. unsigned long reg, val, duration;
  276. char *tmp;
  277. unsigned int freq, channel;
  278. unsigned char volume;
  279. int rcode = 1;
  280. #ifdef CONFIG_STK52XX_REV100
  281. printf ("Revision 100 of STK52XX not supported!\n");
  282. return 1;
  283. #endif
  284. spi_init();
  285. i2s_init();
  286. amplifier_init();
  287. if ((tmp = getenv ("volume")) != NULL) {
  288. volume = simple_strtoul (tmp, NULL, 10);
  289. } else {
  290. volume = DEFAULT_VOL;
  291. }
  292. set_attenuation(volume);
  293. switch (argc) {
  294. case 0:
  295. case 1:
  296. return cmd_usage(cmdtp);
  297. case 2:
  298. if (strncmp(argv[1],"saw",3) == 0) {
  299. printf ("Play sawtooth\n");
  300. rcode = i2s_sawtooth (DEFAULT_DURATION, DEFAULT_FREQ,
  301. LEFT_RIGHT);
  302. return rcode;
  303. } else if (strncmp(argv[1],"squ",3) == 0) {
  304. printf ("Play squarewave\n");
  305. rcode = i2s_squarewave (DEFAULT_DURATION, DEFAULT_FREQ,
  306. LEFT_RIGHT);
  307. return rcode;
  308. }
  309. return cmd_usage(cmdtp);
  310. case 3:
  311. if (strncmp(argv[1],"saw",3) == 0) {
  312. duration = simple_strtoul(argv[2], NULL, 10);
  313. printf ("Play sawtooth\n");
  314. rcode = i2s_sawtooth (duration, DEFAULT_FREQ,
  315. LEFT_RIGHT);
  316. return rcode;
  317. } else if (strncmp(argv[1],"squ",3) == 0) {
  318. duration = simple_strtoul(argv[2], NULL, 10);
  319. printf ("Play squarewave\n");
  320. rcode = i2s_squarewave (duration, DEFAULT_FREQ,
  321. LEFT_RIGHT);
  322. return rcode;
  323. }
  324. return cmd_usage(cmdtp);
  325. case 4:
  326. if (strncmp(argv[1],"saw",3) == 0) {
  327. duration = simple_strtoul(argv[2], NULL, 10);
  328. freq = (unsigned int)simple_strtoul(argv[3], NULL, 10);
  329. printf ("Play sawtooth\n");
  330. rcode = i2s_sawtooth (duration, freq,
  331. LEFT_RIGHT);
  332. return rcode;
  333. } else if (strncmp(argv[1],"squ",3) == 0) {
  334. duration = simple_strtoul(argv[2], NULL, 10);
  335. freq = (unsigned int)simple_strtoul(argv[3], NULL, 10);
  336. printf ("Play squarewave\n");
  337. rcode = i2s_squarewave (duration, freq,
  338. LEFT_RIGHT);
  339. return rcode;
  340. } else if (strcmp(argv[1],"pcm1772") == 0) {
  341. reg = simple_strtoul(argv[2], NULL, 10);
  342. val = simple_strtoul(argv[3], NULL, 10);
  343. printf("Set PCM1772 %lu. %lu\n", reg, val);
  344. pcm1772_write_reg((uchar)reg, (uchar)val);
  345. return 0;
  346. }
  347. return cmd_usage(cmdtp);
  348. case 5:
  349. if (strncmp(argv[1],"saw",3) == 0) {
  350. duration = simple_strtoul(argv[2], NULL, 10);
  351. freq = (unsigned int)simple_strtoul(argv[3], NULL, 10);
  352. if (strncmp(argv[4],"l",1) == 0)
  353. channel = LEFT;
  354. else if (strncmp(argv[4],"r",1) == 0)
  355. channel = RIGHT;
  356. else
  357. channel = LEFT_RIGHT;
  358. printf ("Play squarewave\n");
  359. rcode = i2s_sawtooth (duration, freq,
  360. channel);
  361. return rcode;
  362. } else if (strncmp(argv[1],"squ",3) == 0) {
  363. duration = simple_strtoul(argv[2], NULL, 10);
  364. freq = (unsigned int)simple_strtoul(argv[3], NULL, 10);
  365. if (strncmp(argv[4],"l",1) == 0)
  366. channel = LEFT;
  367. else if (strncmp(argv[4],"r",1) == 0)
  368. channel = RIGHT;
  369. else
  370. channel = LEFT_RIGHT;
  371. printf ("Play squarewave\n");
  372. rcode = i2s_squarewave (duration, freq,
  373. channel);
  374. return rcode;
  375. }
  376. return cmd_usage(cmdtp);
  377. }
  378. printf ("Usage:\nsound cmd [arg1] [arg2] ...\n");
  379. return 1;
  380. }
  381. static int cmd_wav(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  382. {
  383. unsigned long length, addr;
  384. unsigned char volume;
  385. int rcode = 1;
  386. char *tmp;
  387. #ifdef CONFIG_STK52XX_REV100
  388. printf ("Revision 100 of STK52XX not supported!\n");
  389. return 1;
  390. #endif
  391. spi_init();
  392. i2s_init();
  393. amplifier_init();
  394. switch (argc) {
  395. case 3:
  396. length = simple_strtoul(argv[2], NULL, 16);
  397. addr = simple_strtoul(argv[1], NULL, 16);
  398. break;
  399. case 2:
  400. if ((tmp = getenv ("filesize")) != NULL) {
  401. length = simple_strtoul (tmp, NULL, 16);
  402. } else {
  403. puts ("No filesize provided\n");
  404. return 1;
  405. }
  406. addr = simple_strtoul(argv[1], NULL, 16);
  407. case 1:
  408. if ((tmp = getenv ("filesize")) != NULL) {
  409. length = simple_strtoul (tmp, NULL, 16);
  410. } else {
  411. puts ("No filesize provided\n");
  412. return 1;
  413. }
  414. if ((tmp = getenv ("loadaddr")) != NULL) {
  415. addr = simple_strtoul (tmp, NULL, 16);
  416. } else {
  417. puts ("No loadaddr provided\n");
  418. return 1;
  419. }
  420. break;
  421. default:
  422. printf("Usage:\nwav <addr> <length[s]\n");
  423. return 1;
  424. break;
  425. }
  426. if ((tmp = getenv ("volume")) != NULL) {
  427. volume = simple_strtoul (tmp, NULL, 10);
  428. } else {
  429. volume = DEFAULT_VOL;
  430. }
  431. set_attenuation(volume);
  432. printf("Play wave file at %lX with length %lX\n", addr, length);
  433. rcode = i2s_play_wave(addr, length);
  434. return rcode;
  435. }
  436. static int cmd_beep(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  437. {
  438. unsigned char volume;
  439. unsigned int channel;
  440. int rcode;
  441. char *tmp;
  442. #ifdef CONFIG_STK52XX_REV100
  443. printf ("Revision 100 of STK52XX not supported!\n");
  444. return 1;
  445. #endif
  446. spi_init();
  447. i2s_init();
  448. amplifier_init();
  449. switch (argc) {
  450. case 0:
  451. case 1:
  452. channel = LEFT_RIGHT;
  453. break;
  454. case 2:
  455. if (strncmp(argv[1],"l",1) == 0)
  456. channel = LEFT;
  457. else if (strncmp(argv[1],"r",1) == 0)
  458. channel = RIGHT;
  459. else
  460. channel = LEFT_RIGHT;
  461. break;
  462. default:
  463. return cmd_usage(cmdtp);
  464. }
  465. if ((tmp = getenv ("volume")) != NULL) {
  466. volume = simple_strtoul (tmp, NULL, 10);
  467. } else {
  468. volume = DEFAULT_VOL;
  469. }
  470. set_attenuation(volume);
  471. printf("Beep on ");
  472. if (channel == LEFT)
  473. printf ("left ");
  474. else if (channel == RIGHT)
  475. printf ("right ");
  476. else
  477. printf ("left and right ");
  478. printf ("channel\n");
  479. rcode = i2s_squarewave (DEFAULT_DURATION, DEFAULT_FREQ, channel);
  480. return rcode;
  481. }
  482. #endif
  483. #if defined(CONFIG_STK52XX)
  484. void led_init(void)
  485. {
  486. struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio *)MPC5XXX_GPIO;
  487. struct mpc5xxx_gpt_0_7 *gpt = (struct mpc5xxx_gpt_0_7 *)MPC5XXX_GPT;
  488. /* configure PSC3 for SPI and GPIO */
  489. gpio->port_config &= ~(0x00000F00);
  490. gpio->port_config |= 0x00000800;
  491. gpio->simple_gpioe &= ~(0x00000F00);
  492. gpio->simple_gpioe |= 0x00000F00;
  493. gpio->simple_ddr &= ~(0x00000F00);
  494. gpio->simple_ddr |= 0x00000F00;
  495. /* configure timer 4-7 for simple GPIO output */
  496. gpt->gpt4.emsr |= 0x00000024;
  497. gpt->gpt5.emsr |= 0x00000024;
  498. gpt->gpt6.emsr |= 0x00000024;
  499. gpt->gpt7.emsr |= 0x00000024;
  500. #ifndef CONFIG_TQM5200S
  501. /* enable SM501 GPIO control (in both power modes) */
  502. *(vu_long *) (SM501_MMIO_BASE+SM501_POWER_MODE0_GATE) |=
  503. POWER_MODE_GATE_GPIO_PWM_I2C;
  504. *(vu_long *) (SM501_MMIO_BASE+SM501_POWER_MODE1_GATE) |=
  505. POWER_MODE_GATE_GPIO_PWM_I2C;
  506. /* configure SM501 gpio pins 24-27 as output */
  507. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_CTRL_LOW) &= ~(0xF << 24);
  508. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_DIR_LOW) |= (0xF << 24);
  509. /* configure SM501 gpio pins 48-51 as output */
  510. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_DIR_HIGH) |= (0xF << 16);
  511. #endif /* !CONFIG_TQM5200S */
  512. }
  513. /*
  514. * return 1 if led number unknown
  515. * return 0 else
  516. */
  517. int do_led(char * const argv[])
  518. {
  519. struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio *)MPC5XXX_GPIO;
  520. struct mpc5xxx_gpt_0_7 *gpt = (struct mpc5xxx_gpt_0_7 *)MPC5XXX_GPT;
  521. switch (simple_strtoul(argv[2], NULL, 10)) {
  522. case 0:
  523. if (strcmp (argv[3], "on") == 0) {
  524. gpio->simple_dvo |= (1 << 8);
  525. } else {
  526. gpio->simple_dvo &= ~(1 << 8);
  527. }
  528. break;
  529. case 1:
  530. if (strcmp (argv[3], "on") == 0) {
  531. gpio->simple_dvo |= (1 << 9);
  532. } else {
  533. gpio->simple_dvo &= ~(1 << 9);
  534. }
  535. break;
  536. case 2:
  537. if (strcmp (argv[3], "on") == 0) {
  538. gpio->simple_dvo |= (1 << 10);
  539. } else {
  540. gpio->simple_dvo &= ~(1 << 10);
  541. }
  542. break;
  543. case 3:
  544. if (strcmp (argv[3], "on") == 0) {
  545. gpio->simple_dvo |= (1 << 11);
  546. } else {
  547. gpio->simple_dvo &= ~(1 << 11);
  548. }
  549. break;
  550. case 4:
  551. if (strcmp (argv[3], "on") == 0) {
  552. gpt->gpt4.emsr |= (1 << 4);
  553. } else {
  554. gpt->gpt4.emsr &= ~(1 << 4);
  555. }
  556. break;
  557. case 5:
  558. if (strcmp (argv[3], "on") == 0) {
  559. gpt->gpt5.emsr |= (1 << 4);
  560. } else {
  561. gpt->gpt5.emsr &= ~(1 << 4);
  562. }
  563. break;
  564. case 6:
  565. if (strcmp (argv[3], "on") == 0) {
  566. gpt->gpt6.emsr |= (1 << 4);
  567. } else {
  568. gpt->gpt6.emsr &= ~(1 << 4);
  569. }
  570. break;
  571. case 7:
  572. if (strcmp (argv[3], "on") == 0) {
  573. gpt->gpt7.emsr |= (1 << 4);
  574. } else {
  575. gpt->gpt7.emsr &= ~(1 << 4);
  576. }
  577. break;
  578. #ifndef CONFIG_TQM5200S
  579. case 24:
  580. if (strcmp (argv[3], "on") == 0) {
  581. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_LOW) |=
  582. (0x1 << 24);
  583. } else {
  584. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_LOW) &=
  585. ~(0x1 << 24);
  586. }
  587. break;
  588. case 25:
  589. if (strcmp (argv[3], "on") == 0) {
  590. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_LOW) |=
  591. (0x1 << 25);
  592. } else {
  593. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_LOW) &=
  594. ~(0x1 << 25);
  595. }
  596. break;
  597. case 26:
  598. if (strcmp (argv[3], "on") == 0) {
  599. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_LOW) |=
  600. (0x1 << 26);
  601. } else {
  602. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_LOW) &=
  603. ~(0x1 << 26);
  604. }
  605. break;
  606. case 27:
  607. if (strcmp (argv[3], "on") == 0) {
  608. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_LOW) |=
  609. (0x1 << 27);
  610. } else {
  611. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_LOW) &=
  612. ~(0x1 << 27);
  613. }
  614. break;
  615. case 48:
  616. if (strcmp (argv[3], "on") == 0) {
  617. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) |=
  618. (0x1 << 16);
  619. } else {
  620. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) &=
  621. ~(0x1 << 16);
  622. }
  623. break;
  624. case 49:
  625. if (strcmp (argv[3], "on") == 0) {
  626. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) |=
  627. (0x1 << 17);
  628. } else {
  629. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) &=
  630. ~(0x1 << 17);
  631. }
  632. break;
  633. case 50:
  634. if (strcmp (argv[3], "on") == 0) {
  635. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) |=
  636. (0x1 << 18);
  637. } else {
  638. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) &=
  639. ~(0x1 << 18);
  640. }
  641. break;
  642. case 51:
  643. if (strcmp (argv[3], "on") == 0) {
  644. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) |=
  645. (0x1 << 19);
  646. } else {
  647. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) &=
  648. ~(0x1 << 19);
  649. }
  650. break;
  651. #endif /* !CONFIG_TQM5200S */
  652. default:
  653. printf ("%s: invalid led number %s\n", __FUNCTION__, argv[2]);
  654. return 1;
  655. }
  656. return 0;
  657. }
  658. #endif
  659. #if defined(CONFIG_STK52XX) || defined(CONFIG_FO300)
  660. /*
  661. * return 1 on CAN initialization failure
  662. * return 0 if no failure
  663. */
  664. int can_init(void)
  665. {
  666. static int init_done = 0;
  667. int i;
  668. struct mpc5xxx_mscan *can1 =
  669. (struct mpc5xxx_mscan *)(CONFIG_SYS_MBAR + 0x0900);
  670. struct mpc5xxx_mscan *can2 =
  671. (struct mpc5xxx_mscan *)(CONFIG_SYS_MBAR + 0x0980);
  672. /* GPIO configuration of the CAN pins is done in TQM5200.h */
  673. if (!init_done) {
  674. /* init CAN 1 */
  675. can1->canctl1 |= 0x80; /* CAN enable */
  676. udelay(100);
  677. i = 0;
  678. can1->canctl0 |= 0x02; /* sleep mode */
  679. /* wait until sleep mode reached */
  680. while (!(can1->canctl1 & 0x02)) {
  681. udelay(10);
  682. i++;
  683. if (i == 10) {
  684. printf ("%s: CAN1 initialize error, "
  685. "can not enter sleep mode!\n",
  686. __FUNCTION__);
  687. return 1;
  688. }
  689. }
  690. i = 0;
  691. can1->canctl0 = 0x01; /* enter init mode */
  692. /* wait until init mode reached */
  693. while (!(can1->canctl1 & 0x01)) {
  694. udelay(10);
  695. i++;
  696. if (i == 10) {
  697. printf ("%s: CAN1 initialize error, "
  698. "can not enter init mode!\n",
  699. __FUNCTION__);
  700. return 1;
  701. }
  702. }
  703. can1->canctl1 = 0x80;
  704. can1->canctl1 |= 0x40;
  705. can1->canbtr0 = 0x0F;
  706. can1->canbtr1 = 0x7F;
  707. can1->canidac &= ~(0x30);
  708. can1->canidar1 = 0x00;
  709. can1->canidar3 = 0x00;
  710. can1->canidar5 = 0x00;
  711. can1->canidar7 = 0x00;
  712. can1->canidmr0 = 0xFF;
  713. can1->canidmr1 = 0xFF;
  714. can1->canidmr2 = 0xFF;
  715. can1->canidmr3 = 0xFF;
  716. can1->canidmr4 = 0xFF;
  717. can1->canidmr5 = 0xFF;
  718. can1->canidmr6 = 0xFF;
  719. can1->canidmr7 = 0xFF;
  720. i = 0;
  721. can1->canctl0 &= ~(0x01); /* leave init mode */
  722. can1->canctl0 &= ~(0x02);
  723. /* wait until init and sleep mode left */
  724. while ((can1->canctl1 & 0x01) || (can1->canctl1 & 0x02)) {
  725. udelay(10);
  726. i++;
  727. if (i == 10) {
  728. printf ("%s: CAN1 initialize error, "
  729. "can not leave init/sleep mode!\n",
  730. __FUNCTION__);
  731. return 1;
  732. }
  733. }
  734. /* init CAN 2 */
  735. can2->canctl1 |= 0x80; /* CAN enable */
  736. udelay(100);
  737. i = 0;
  738. can2->canctl0 |= 0x02; /* sleep mode */
  739. /* wait until sleep mode reached */
  740. while (!(can2->canctl1 & 0x02)) {
  741. udelay(10);
  742. i++;
  743. if (i == 10) {
  744. printf ("%s: CAN2 initialize error, "
  745. "can not enter sleep mode!\n",
  746. __FUNCTION__);
  747. return 1;
  748. }
  749. }
  750. i = 0;
  751. can2->canctl0 = 0x01; /* enter init mode */
  752. /* wait until init mode reached */
  753. while (!(can2->canctl1 & 0x01)) {
  754. udelay(10);
  755. i++;
  756. if (i == 10) {
  757. printf ("%s: CAN2 initialize error, "
  758. "can not enter init mode!\n",
  759. __FUNCTION__);
  760. return 1;
  761. }
  762. }
  763. can2->canctl1 = 0x80;
  764. can2->canctl1 |= 0x40;
  765. can2->canbtr0 = 0x0F;
  766. can2->canbtr1 = 0x7F;
  767. can2->canidac &= ~(0x30);
  768. can2->canidar1 = 0x00;
  769. can2->canidar3 = 0x00;
  770. can2->canidar5 = 0x00;
  771. can2->canidar7 = 0x00;
  772. can2->canidmr0 = 0xFF;
  773. can2->canidmr1 = 0xFF;
  774. can2->canidmr2 = 0xFF;
  775. can2->canidmr3 = 0xFF;
  776. can2->canidmr4 = 0xFF;
  777. can2->canidmr5 = 0xFF;
  778. can2->canidmr6 = 0xFF;
  779. can2->canidmr7 = 0xFF;
  780. can2->canctl0 &= ~(0x01); /* leave init mode */
  781. can2->canctl0 &= ~(0x02);
  782. i = 0;
  783. /* wait until init mode left */
  784. while ((can2->canctl1 & 0x01) || (can2->canctl1 & 0x02)) {
  785. udelay(10);
  786. i++;
  787. if (i == 10) {
  788. printf ("%s: CAN2 initialize error, "
  789. "can not leave init/sleep mode!\n",
  790. __FUNCTION__);
  791. return 1;
  792. }
  793. }
  794. init_done = 1;
  795. }
  796. return 0;
  797. }
  798. /*
  799. * return 1 on CAN failure
  800. * return 0 if no failure
  801. */
  802. int do_can(char * const argv[])
  803. {
  804. int i;
  805. struct mpc5xxx_mscan *can1 =
  806. (struct mpc5xxx_mscan *)(CONFIG_SYS_MBAR + 0x0900);
  807. struct mpc5xxx_mscan *can2 =
  808. (struct mpc5xxx_mscan *)(CONFIG_SYS_MBAR + 0x0980);
  809. /* send a message on CAN1 */
  810. can1->cantbsel = 0x01;
  811. can1->cantxfg.idr[0] = 0x55;
  812. can1->cantxfg.idr[1] = 0x00;
  813. can1->cantxfg.idr[1] &= ~0x8;
  814. can1->cantxfg.idr[1] &= ~0x10;
  815. can1->cantxfg.dsr[0] = 0xCC;
  816. can1->cantxfg.dlr = 1;
  817. can1->cantxfg.tbpr = 0;
  818. can1->cantflg = 0x01;
  819. i = 0;
  820. while ((can1->cantflg & 0x01) == 0) {
  821. i++;
  822. if (i == 10) {
  823. printf ("%s: CAN1 send timeout, "
  824. "can not send message!\n",
  825. __FUNCTION__);
  826. return 1;
  827. }
  828. udelay(1000);
  829. }
  830. udelay(1000);
  831. i = 0;
  832. while (!(can2->canrflg & 0x01)) {
  833. i++;
  834. if (i == 10) {
  835. printf ("%s: CAN2 receive timeout, "
  836. "no message received!\n",
  837. __FUNCTION__);
  838. return 1;
  839. }
  840. udelay(1000);
  841. }
  842. if (can2->canrxfg.dsr[0] != 0xCC) {
  843. printf ("%s: CAN2 receive error, "
  844. "data mismatch!\n",
  845. __FUNCTION__);
  846. return 1;
  847. }
  848. /* send a message on CAN2 */
  849. can2->cantbsel = 0x01;
  850. can2->cantxfg.idr[0] = 0x55;
  851. can2->cantxfg.idr[1] = 0x00;
  852. can2->cantxfg.idr[1] &= ~0x8;
  853. can2->cantxfg.idr[1] &= ~0x10;
  854. can2->cantxfg.dsr[0] = 0xCC;
  855. can2->cantxfg.dlr = 1;
  856. can2->cantxfg.tbpr = 0;
  857. can2->cantflg = 0x01;
  858. i = 0;
  859. while ((can2->cantflg & 0x01) == 0) {
  860. i++;
  861. if (i == 10) {
  862. printf ("%s: CAN2 send error, "
  863. "can not send message!\n",
  864. __FUNCTION__);
  865. return 1;
  866. }
  867. udelay(1000);
  868. }
  869. udelay(1000);
  870. i = 0;
  871. while (!(can1->canrflg & 0x01)) {
  872. i++;
  873. if (i == 10) {
  874. printf ("%s: CAN1 receive timeout, "
  875. "no message received!\n",
  876. __FUNCTION__);
  877. return 1;
  878. }
  879. udelay(1000);
  880. }
  881. if (can1->canrxfg.dsr[0] != 0xCC) {
  882. printf ("%s: CAN1 receive error 0x%02x\n",
  883. __FUNCTION__, (can1->canrxfg.dsr[0]));
  884. return 1;
  885. }
  886. return 0;
  887. }
  888. /*
  889. * return 1 if rs232 port unknown
  890. * return 2 on txd/rxd failure (only rs232 2)
  891. * return 3 on rts/cts failure
  892. * return 0 if no failure
  893. */
  894. int do_rs232(char * const argv[])
  895. {
  896. int error_status = 0;
  897. struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio *)MPC5XXX_GPIO;
  898. struct mpc5xxx_psc *psc1 = (struct mpc5xxx_psc *)MPC5XXX_PSC1;
  899. switch (simple_strtoul(argv[2], NULL, 10)) {
  900. case 1:
  901. /* check RTS <-> CTS loop */
  902. /* set rts to 0 */
  903. psc1->op1 |= 0x01;
  904. /* wait some time before requesting status */
  905. udelay(10);
  906. /* check status at cts */
  907. if ((psc1->ip & 0x01) != 0) {
  908. error_status = 3;
  909. printf ("%s: failure at rs232_1, cts status is %d "
  910. "(should be 0)\n",
  911. __FUNCTION__, (psc1->ip & 0x01));
  912. }
  913. /* set rts to 1 */
  914. psc1->op0 |= 0x01;
  915. /* wait some time before requesting status */
  916. udelay(10);
  917. /* check status at cts */
  918. if ((psc1->ip & 0x01) != 1) {
  919. error_status = 3;
  920. printf ("%s: failure at rs232_1, cts status is %d "
  921. "(should be 1)\n",
  922. __FUNCTION__, (psc1->ip & 0x01));
  923. }
  924. break;
  925. case 2:
  926. /* set PSC3_0, PSC3_2 as output and PSC3_1, PSC3_3 as input */
  927. gpio->simple_ddr &= ~(0x00000F00);
  928. gpio->simple_ddr |= 0x00000500;
  929. /* check TXD <-> RXD loop */
  930. /* set TXD to 1 */
  931. gpio->simple_dvo |= (1 << 8);
  932. /* wait some time before requesting status */
  933. udelay(10);
  934. if ((gpio->simple_ival & 0x00000200) != 0x00000200) {
  935. error_status = 2;
  936. printf ("%s: failure at rs232_2, rxd status is %d "
  937. "(should be 1)\n",
  938. __FUNCTION__,
  939. (gpio->simple_ival & 0x00000200) >> 9);
  940. }
  941. /* set TXD to 0 */
  942. gpio->simple_dvo &= ~(1 << 8);
  943. /* wait some time before requesting status */
  944. udelay(10);
  945. if ((gpio->simple_ival & 0x00000200) != 0x00000000) {
  946. error_status = 2;
  947. printf ("%s: failure at rs232_2, rxd status is %d "
  948. "(should be 0)\n",
  949. __FUNCTION__,
  950. (gpio->simple_ival & 0x00000200) >> 9);
  951. }
  952. /* check RTS <-> CTS loop */
  953. /* set RTS to 1 */
  954. gpio->simple_dvo |= (1 << 10);
  955. /* wait some time before requesting status */
  956. udelay(10);
  957. if ((gpio->simple_ival & 0x00000800) != 0x00000800) {
  958. error_status = 3;
  959. printf ("%s: failure at rs232_2, cts status is %d "
  960. "(should be 1)\n",
  961. __FUNCTION__,
  962. (gpio->simple_ival & 0x00000800) >> 11);
  963. }
  964. /* set RTS to 0 */
  965. gpio->simple_dvo &= ~(1 << 10);
  966. /* wait some time before requesting status */
  967. udelay(10);
  968. if ((gpio->simple_ival & 0x00000800) != 0x00000000) {
  969. error_status = 3;
  970. printf ("%s: failure at rs232_2, cts status is %d "
  971. "(should be 0)\n",
  972. __FUNCTION__,
  973. (gpio->simple_ival & 0x00000800) >> 11);
  974. }
  975. /* set PSC3_0, PSC3_1, PSC3_2 and PSC3_3 as output */
  976. gpio->simple_ddr &= ~(0x00000F00);
  977. gpio->simple_ddr |= 0x00000F00;
  978. break;
  979. default:
  980. printf ("%s: invalid rs232 number %s\n", __FUNCTION__, argv[2]);
  981. error_status = 1;
  982. break;
  983. }
  984. return error_status;
  985. }
  986. #if !defined(CONFIG_FO300) && !defined(CONFIG_TQM5200S)
  987. static void sm501_backlight (unsigned int state)
  988. {
  989. if (state == BL_ON) {
  990. *(vu_long *)(SM501_MMIO_BASE+SM501_PANEL_DISPLAY_CONTROL) |=
  991. (1 << 26) | (1 << 27);
  992. } else if (state == BL_OFF)
  993. *(vu_long *)(SM501_MMIO_BASE+SM501_PANEL_DISPLAY_CONTROL) &=
  994. ~((1 << 26) | (1 << 27));
  995. }
  996. #endif /* !CONFIG_FO300 & !CONFIG_TQM5200S */
  997. int cmd_fkt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  998. {
  999. int rcode;
  1000. #ifdef CONFIG_STK52XX_REV100
  1001. printf ("Revision 100 of STK52XX not supported!\n");
  1002. return 1;
  1003. #endif
  1004. #if defined(CONFIG_STK52XX)
  1005. led_init();
  1006. #endif
  1007. can_init();
  1008. switch (argc) {
  1009. case 0:
  1010. case 1:
  1011. break;
  1012. case 2:
  1013. if (strncmp (argv[1], "can", 3) == 0) {
  1014. rcode = do_can (argv);
  1015. if (rcode == 0)
  1016. printf ("OK\n");
  1017. else
  1018. printf ("Error\n");
  1019. return rcode;
  1020. }
  1021. break;
  1022. case 3:
  1023. if (strncmp (argv[1], "rs232", 3) == 0) {
  1024. rcode = do_rs232 (argv);
  1025. if (rcode == 0)
  1026. printf ("OK\n");
  1027. else
  1028. printf ("Error\n");
  1029. return rcode;
  1030. #if !defined(CONFIG_FO300) && !defined(CONFIG_TQM5200S)
  1031. } else if (strncmp (argv[1], "backlight", 4) == 0) {
  1032. if (strncmp (argv[2], "on", 2) == 0) {
  1033. sm501_backlight (BL_ON);
  1034. return 0;
  1035. }
  1036. else if (strncmp (argv[2], "off", 3) == 0) {
  1037. sm501_backlight (BL_OFF);
  1038. return 0;
  1039. }
  1040. #endif /* !CONFIG_FO300 & !CONFIG_TQM5200S */
  1041. }
  1042. break;
  1043. #if defined(CONFIG_STK52XX)
  1044. case 4:
  1045. if (strcmp (argv[1], "led") == 0) {
  1046. return (do_led (argv));
  1047. }
  1048. break;
  1049. #endif
  1050. default:
  1051. break;
  1052. }
  1053. printf ("Usage:\nfkt cmd [arg1] [arg2] ...\n");
  1054. return 1;
  1055. }
  1056. U_BOOT_CMD(
  1057. sound , 5, 1, cmd_sound,
  1058. "Sound sub-system",
  1059. "saw [duration] [freq] [channel]\n"
  1060. " - generate sawtooth for 'duration' ms with frequency 'freq'\n"
  1061. " on left \"l\" or right \"r\" channel\n"
  1062. "sound square [duration] [freq] [channel]\n"
  1063. " - generate squarewave for 'duration' ms with frequency 'freq'\n"
  1064. " on left \"l\" or right \"r\" channel\n"
  1065. "pcm1772 reg val"
  1066. );
  1067. U_BOOT_CMD(
  1068. wav , 3, 1, cmd_wav,
  1069. "play wav file",
  1070. "[addr] [bytes]\n"
  1071. " - play wav file at address 'addr' with length 'bytes'"
  1072. );
  1073. U_BOOT_CMD(
  1074. beep , 2, 1, cmd_beep,
  1075. "play short beep",
  1076. "[channel]\n"
  1077. " - play short beep on \"l\"eft or \"r\"ight channel"
  1078. );
  1079. #endif /* CONFIG_STK52XX || CONFIG_FO300 */
  1080. #if defined(CONFIG_STK52XX)
  1081. U_BOOT_CMD(
  1082. fkt , 4, 1, cmd_fkt,
  1083. "Function test routines",
  1084. "led number on/off\n"
  1085. " - 'number's like printed on STK52XX board\n"
  1086. "fkt can\n"
  1087. " - loopback plug for X83 required\n"
  1088. "fkt rs232 number\n"
  1089. " - loopback plug(s) for X2 required"
  1090. #ifndef CONFIG_TQM5200S
  1091. "\n"
  1092. "fkt backlight on/off\n"
  1093. " - switch backlight on or off"
  1094. #endif /* !CONFIG_TQM5200S */
  1095. );
  1096. #elif defined(CONFIG_FO300)
  1097. U_BOOT_CMD(
  1098. fkt , 3, 1, cmd_fkt,
  1099. "Function test routines",
  1100. "fkt can\n"
  1101. " - loopback plug for X16/X29 required\n"
  1102. "fkt rs232 number\n"
  1103. " - loopback plug(s) for X21/X22 required"
  1104. );
  1105. #endif
  1106. #endif