1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#include <common.h>
28#include <asm/bitops.h>
29#include <command.h>
30#include <asm/io.h>
31#include <asm/processor.h>
32#include <asm/mpc512x.h>
33#include <fdt_support.h>
34#include <flash.h>
35#ifdef CONFIG_MISC_INIT_R
36#include <i2c.h>
37#endif
38#include <serial.h>
39#include <jffs2/load_kernel.h>
40#include <mtd_node.h>
41
42DECLARE_GLOBAL_DATA_PTR;
43
44extern flash_info_t flash_info[];
45ulong flash_get_size (phys_addr_t base, int banknum);
46
47
48#define SCCR1_CLOCKS_EN (CLOCK_SCCR1_CFG_EN | \
49 CLOCK_SCCR1_LPC_EN | \
50 CLOCK_SCCR1_NFC_EN | \
51 CLOCK_SCCR1_PSC_EN(CONFIG_PSC_CONSOLE) | \
52 CLOCK_SCCR1_PSCFIFO_EN | \
53 CLOCK_SCCR1_DDR_EN | \
54 CLOCK_SCCR1_FEC_EN | \
55 CLOCK_SCCR1_TPR_EN)
56
57#define SCCR2_CLOCKS_EN (CLOCK_SCCR2_MEM_EN | \
58 CLOCK_SCCR2_SPDIF_EN | \
59 CLOCK_SCCR2_DIU_EN | \
60 CLOCK_SCCR2_I2C_EN)
61
62int board_early_init_f(void)
63{
64 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
65
66
67
68
69 out_be32(&im->sysconf.lpcs1aw,
70 CSAW_START(CONFIG_SYS_FLASH1_BASE) |
71 CSAW_STOP(CONFIG_SYS_FLASH1_BASE, CONFIG_SYS_FLASH_SIZE)
72 );
73 out_be32(&im->lpc.cs_cfg[1], CONFIG_SYS_CS1_CFG);
74
75
76
77
78 out_be32(&im->sysconf.lpcs2aw,
79 CSAW_START(CONFIG_SYS_MRAM_BASE) |
80 CSAW_STOP(CONFIG_SYS_MRAM_BASE, CONFIG_SYS_MRAM_SIZE)
81 );
82 out_be32(&im->lpc.cs_cfg[2], CONFIG_SYS_CS2_CFG);
83
84 sync_law(&im->sysconf.lpcs2aw);
85
86
87
88
89 out_be32(&im->lpc.cs_cfg[0], CONFIG_SYS_CS0_CFG);
90 out_be32(&im->lpc.altr, CONFIG_SYS_CS_ALETIMING);
91
92
93
94
95 out_be32(&im->clk.sccr[0], SCCR1_CLOCKS_EN);
96 out_be32(&im->clk.sccr[1], SCCR2_CLOCKS_EN);
97#if defined(CONFIG_IIM) || defined(CONFIG_CMD_FUSE)
98 setbits_be32(&im->clk.sccr[1], CLOCK_SCCR2_IIM_EN);
99#endif
100
101 return 0;
102}
103
104sdram_conf_t mddrc_config[] = {
105 {
106 (512 << 20),
107 {
108 CONFIG_SYS_MDDRC_SYS_CFG,
109 CONFIG_SYS_MDDRC_TIME_CFG0,
110 CONFIG_SYS_MDDRC_TIME_CFG1,
111 CONFIG_SYS_MDDRC_TIME_CFG2
112 }
113 },
114 {
115 (128 << 20),
116 {
117 CONFIG_SYS_MDDRC_SYS_CFG_ALT1,
118 CONFIG_SYS_MDDRC_TIME_CFG0_ALT1,
119 CONFIG_SYS_MDDRC_TIME_CFG1_ALT1,
120 CONFIG_SYS_MDDRC_TIME_CFG2_ALT1
121 }
122 },
123};
124
125phys_size_t initdram (int board_type)
126{
127 int i;
128 u32 msize = 0;
129 u32 pdm360ng_init_seq[] = {
130 CONFIG_SYS_DDRCMD_NOP,
131 CONFIG_SYS_DDRCMD_NOP,
132 CONFIG_SYS_DDRCMD_NOP,
133 CONFIG_SYS_DDRCMD_NOP,
134 CONFIG_SYS_DDRCMD_NOP,
135 CONFIG_SYS_DDRCMD_NOP,
136 CONFIG_SYS_DDRCMD_NOP,
137 CONFIG_SYS_DDRCMD_NOP,
138 CONFIG_SYS_DDRCMD_NOP,
139 CONFIG_SYS_DDRCMD_NOP,
140 CONFIG_SYS_DDRCMD_PCHG_ALL,
141 CONFIG_SYS_DDRCMD_NOP,
142 CONFIG_SYS_DDRCMD_RFSH,
143 CONFIG_SYS_DDRCMD_NOP,
144 CONFIG_SYS_DDRCMD_RFSH,
145 CONFIG_SYS_DDRCMD_NOP,
146 CONFIG_SYS_MICRON_INIT_DEV_OP,
147 CONFIG_SYS_DDRCMD_NOP,
148 CONFIG_SYS_DDRCMD_EM2,
149 CONFIG_SYS_DDRCMD_NOP,
150 CONFIG_SYS_DDRCMD_PCHG_ALL,
151 CONFIG_SYS_DDRCMD_EM2,
152 CONFIG_SYS_DDRCMD_EM3,
153 CONFIG_SYS_DDRCMD_EN_DLL,
154 CONFIG_SYS_DDRCMD_RES_DLL,
155 CONFIG_SYS_DDRCMD_PCHG_ALL,
156 CONFIG_SYS_DDRCMD_RFSH,
157 CONFIG_SYS_DDRCMD_RFSH,
158 CONFIG_SYS_MICRON_INIT_DEV_OP,
159 CONFIG_SYS_DDRCMD_OCD_DEFAULT,
160 CONFIG_SYS_DDRCMD_OCD_EXIT,
161 CONFIG_SYS_DDRCMD_PCHG_ALL,
162 CONFIG_SYS_DDRCMD_NOP
163 };
164
165 for (i = 0; i < ARRAY_SIZE(mddrc_config); i++) {
166 msize = fixed_sdram(&mddrc_config[i].cfg, pdm360ng_init_seq,
167 ARRAY_SIZE(pdm360ng_init_seq));
168 if (msize == mddrc_config[i].size)
169 break;
170 }
171
172 return msize;
173}
174
175#if defined(CONFIG_SERIAL_MULTI)
176static int set_lcd_brightness(char *);
177#endif
178
179int misc_init_r(void)
180{
181 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
182
183
184
185
186 if (flash_info[1].size > 0) {
187 out_be32(&im->sysconf.lpcs1aw,
188 CSAW_START(gd->bd->bi_flashstart + flash_info[1].size) |
189 CSAW_STOP(gd->bd->bi_flashstart + flash_info[1].size,
190 flash_info[1].size));
191 sync_law(&im->sysconf.lpcs1aw);
192
193
194
195 flash_get_size (gd->bd->bi_flashstart + flash_info[1].size, 1);
196 } else {
197
198 out_be32(&im->sysconf.lpcs1aw, 0x01000100);
199 sync_law(&im->sysconf.lpcs1aw);
200 }
201
202 out_be32(&im->sysconf.lpcs0aw,
203 CSAW_START(gd->bd->bi_flashstart) |
204 CSAW_STOP(gd->bd->bi_flashstart, flash_info[0].size));
205 sync_law(&im->sysconf.lpcs0aw);
206
207
208
209
210 flash_get_size (gd->bd->bi_flashstart, 0);
211
212
213
214
215 flash_protect (FLAG_PROTECT_CLEAR,
216 gd->bd->bi_flashstart, 0xffffffff,
217 &flash_info[0]);
218
219
220 flash_protect (FLAG_PROTECT_SET,
221 CONFIG_SYS_MONITOR_BASE,
222 CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN - 1,
223 &flash_info[0]);
224
225
226 flash_protect (FLAG_PROTECT_SET,
227 CONFIG_ENV_ADDR,
228 CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1,
229 &flash_info[0]);
230
231#ifdef CONFIG_ENV_ADDR_REDUND
232
233 flash_protect (FLAG_PROTECT_SET,
234 CONFIG_ENV_ADDR_REDUND,
235 CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
236 &flash_info[0]);
237#endif
238
239#ifdef CONFIG_FSL_DIU_FB
240#if defined(CONFIG_SERIAL_MULTI)
241 set_lcd_brightness(0);
242#endif
243
244 setbits_be32(&im->gpio.gpdir, 0x01040000);
245 clrsetbits_be32(&im->gpio.gpdat, 0x01000000, 0x00040000);
246#endif
247
248#if defined(CONFIG_HARD_I2C)
249 if (!getenv("ethaddr")) {
250 uchar buf[6];
251 uchar ifm_oui[3] = { 0, 2, 1, };
252 int ret;
253
254
255 i2c_set_bus_num(CONFIG_SYS_I2C_EEPROM_BUS_NUM);
256
257
258 ret = i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR,
259 CONFIG_SYS_I2C_EEPROM_MAC_OFFSET, 1, buf, 6);
260 if (ret != 0) {
261 printf("Error: Unable to read MAC from I2C"
262 " EEPROM at address %02X:%02X\n",
263 CONFIG_SYS_I2C_EEPROM_ADDR,
264 CONFIG_SYS_I2C_EEPROM_MAC_OFFSET);
265 return 1;
266 }
267
268
269 if (memcmp(buf, ifm_oui, sizeof(ifm_oui))) {
270 printf("Illegal MAC address in EEPROM: %pM\n", buf);
271 return 1;
272 }
273
274 eth_setenv_enetaddr("ethaddr", buf);
275 }
276#endif
277
278 return 0;
279}
280
281static iopin_t ioregs_init[] = {
282
283 {
284 offsetof(struct ioctrl512x, io_control_pata_ce1), 1, 0,
285 IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(1) |
286 IO_PIN_PUE(1) | IO_PIN_ST(0) | IO_PIN_DS(3)
287 },
288
289 {
290 offsetof(struct ioctrl512x, io_control_pata_ce2), 1, 0,
291 IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
292 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
293 },
294
295 {
296 offsetof(struct ioctrl512x, io_control_pata_isolate), 1, 0,
297 IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
298 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
299 },
300
301 {
302 offsetof(struct ioctrl512x, io_control_pata_iochrdy), 1, 0,
303 IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
304 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
305 },
306
307
308 {
309 offsetof(struct ioctrl512x, io_control_pci_ad31), 2, 0,
310 IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
311 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(1)
312 },
313
314
315 {
316 offsetof(struct ioctrl512x, io_control_pci_ad29), 12, 0,
317 IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
318 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(1)
319 },
320
321
322 {
323 offsetof(struct ioctrl512x, io_control_pci_ad17), 3, 0,
324 IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
325 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(1)
326 },
327
328 {
329 offsetof(struct ioctrl512x, io_control_pci_ad14), 1, 0,
330 IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
331 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(1)
332 },
333
334
335 {
336 offsetof(struct ioctrl512x, io_control_pci_ad13), 2, 0,
337 IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
338 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(1)
339 },
340
341
342
343 {
344 offsetof(struct ioctrl512x, io_control_pci_ad11), 12, 0,
345 IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
346 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(1)
347 },
348
349
350 {
351 offsetof(struct ioctrl512x, io_control_pci_cbe0), 22, 0,
352 IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
353 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(1)
354 },
355
356
357 {
358 offsetof(struct ioctrl512x, io_control_spdif_txclk), 3, 0,
359 IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
360 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
361 },
362
363 {
364 offsetof(struct ioctrl512x, io_control_irq1), 1, 0,
365 IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
366 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
367 },
368
369 {
370 offsetof(struct ioctrl512x, io_control_can1_tx), 2, 0,
371 IO_PIN_FMUX(0) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
372 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
373 },
374
375
376 {
377 offsetof(struct ioctrl512x, io_control_j1850_tx), 2, 0,
378 IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
379 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
380 },
381
382
383 {
384 offsetof(struct ioctrl512x, io_control_psc0_0), 2, 0,
385 IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
386 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
387 },
388
389
390 {
391 offsetof(struct ioctrl512x, io_control_psc0_4), 3, 0,
392 IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
393 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
394 },
395
396
397 {
398 offsetof(struct ioctrl512x, io_control_psc1_4), 2, 0,
399 IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
400 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
401 },
402
403 {
404 offsetof(struct ioctrl512x, io_control_psc2_1), 1, 0,
405 IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
406 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
407 },
408
409
410 {
411 offsetof(struct ioctrl512x, io_control_psc2_4), 3, 0,
412 IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
413 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
414 },
415
416 {
417 offsetof(struct ioctrl512x, io_control_psc3_4), 1, 0,
418 IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
419 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
420 },
421
422
423 {
424 offsetof(struct ioctrl512x, io_control_psc4_0), 2, 0,
425 IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
426 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
427 },
428
429 {
430 offsetof(struct ioctrl512x, io_control_psc4_4), 1, 0,
431 IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(1) |
432 IO_PIN_PUE(1) | IO_PIN_ST(0) | IO_PIN_DS(0)
433 },
434
435
436 {
437 offsetof(struct ioctrl512x, io_control_psc5_0), 5, 0,
438 IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
439 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
440 },
441
442
443 {
444 offsetof(struct ioctrl512x, io_control_psc6_0), 2, 0,
445 IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
446 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
447 },
448
449 {
450 offsetof(struct ioctrl512x, io_control_psc6_4), 1, 0,
451 IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
452 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
453 },
454
455 {
456 offsetof(struct ioctrl512x, io_control_psc7_0), 1, 0,
457 IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
458 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
459 },
460
461
462 {
463 offsetof(struct ioctrl512x, io_control_psc7_2), 3, 0,
464 IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
465 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
466 },
467
468 {
469 offsetof(struct ioctrl512x, io_control_psc8_4), 1, 0,
470 IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
471 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
472 },
473
474
475 {
476 offsetof(struct ioctrl512x, io_control_psc10_3), 4, 0,
477 IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
478 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
479 },
480
481 {
482 offsetof(struct ioctrl512x, io_control_psc11_4), 1, 0,
483 IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
484 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
485 }
486};
487
488int checkboard (void)
489{
490 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
491
492 puts("Board: PDM360NG\n");
493
494
495
496 iopin_initialize(ioregs_init, ARRAY_SIZE(ioregs_init));
497
498
499 setbits_be32(&im->io_ctrl.io_control_gp,
500 (1 << 0) |
501 (1 << 5));
502
503
504 setbits_be32(&im->gpio.gpdir, 0x80);
505 setbits_be32(&im->gpio.gpdat, 0x80);
506
507 return 0;
508}
509
510#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
511#ifdef CONFIG_FDT_FIXUP_PARTITIONS
512struct node_info nodes[] = {
513 { "fsl,mpc5121-nfc", MTD_DEV_TYPE_NAND, },
514 { "cfi-flash", MTD_DEV_TYPE_NOR, },
515};
516#endif
517
518#if defined(CONFIG_VIDEO)
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538static unsigned char edid_buf[128] = {
539 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
540 0x42, 0xC9, 0x34, 0x12, 0x01, 0x00, 0x00, 0x00,
541 0x0A, 0x0C, 0x01, 0x03, 0x80, 0x98, 0x5B, 0x78,
542 0xCA, 0x7E, 0x50, 0xA0, 0x58, 0x4E, 0x96, 0x25,
543 0x1E, 0x50, 0x54, 0x00, 0x00, 0x00, 0x01, 0x01,
544 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
545 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x80, 0x0C,
546 0x20, 0x00, 0x31, 0xE0, 0x2D, 0x10, 0x2A, 0x80,
547 0x12, 0x08, 0x30, 0xE4, 0x10, 0x00, 0x00, 0x18,
548 0x00, 0x00, 0x00, 0xFD, 0x00, 0x38, 0x3C, 0x1F,
549 0x3C, 0x04, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20,
550 0x20, 0x20, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x50,
551 0x4D, 0x30, 0x37, 0x30, 0x57, 0x4C, 0x33, 0x0A,
552 0x0A, 0x0A, 0x0A, 0x0A, 0x00, 0x00, 0x00, 0xFF,
553 0x00, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
554 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x00, 0xD4,
555};
556#endif
557
558void ft_board_setup(void *blob, bd_t *bd)
559{
560 u32 val[8];
561 int rc, i = 0;
562
563 ft_cpu_setup(blob, bd);
564 fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
565#ifdef CONFIG_FDT_FIXUP_PARTITIONS
566 fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
567#endif
568#if defined(CONFIG_VIDEO)
569 fdt_add_edid(blob, "fsl,mpc5121-diu", edid_buf);
570#endif
571
572
573 val[i++] = 0;
574 val[i++] = 0;
575 val[i++] = gd->bd->bi_flashstart;
576 val[i++] = gd->bd->bi_flashsize;
577
578
579 val[i++] = 2;
580 val[i++] = 0;
581 val[i++] = CONFIG_SYS_MRAM_BASE;
582 val[i++] = CONFIG_SYS_MRAM_SIZE;
583
584 rc = fdt_find_and_setprop(blob, "/localbus", "ranges",
585 val, i * sizeof(u32), 1);
586 if (rc)
587 printf("Unable to update localbus ranges, err=%s\n",
588 fdt_strerror(rc));
589
590
591 i = 0;
592 val[i++] = 0;
593 val[i++] = 0;
594 val[i++] = flash_info[0].size;
595
596
597 if (flash_info[1].size > 0) {
598 val[i++] = 0;
599 val[i++] = flash_info[0].size;
600 val[i++] = flash_info[1].size;
601 }
602
603 rc = fdt_find_and_setprop(blob, "/localbus/flash", "reg",
604 val, i * sizeof(u32), 1);
605 if (rc)
606 printf("Unable to update flash reg property, err=%s\n",
607 fdt_strerror(rc));
608}
609#endif
610
611#if defined(CONFIG_SERIAL_MULTI)
612
613
614
615
616
617
618#define MAX_BRIGHTNESS 99
619static int set_lcd_brightness(char *brightness)
620{
621 struct stdio_dev *cop_port;
622 char *env;
623 char cmd_buf[20];
624 int val = 0;
625 int cs = 0;
626 int len, i;
627
628 if (brightness) {
629 val = simple_strtol(brightness, NULL, 10);
630 } else {
631 env = getenv("brightness");
632 if (env)
633 val = simple_strtol(env, NULL, 10);
634 }
635
636 if (val < 0)
637 val = 0;
638
639 if (val > MAX_BRIGHTNESS)
640 val = MAX_BRIGHTNESS;
641
642 sprintf(cmd_buf, "$SB;%04d;", val);
643
644 len = strlen(cmd_buf);
645 for (i = 1; i <= len; i++)
646 cs += cmd_buf[i];
647
648 cs = (~cs + 1) & 0xff;
649 sprintf(cmd_buf + len, "%02X\n", cs);
650
651
652 cop_port = open_port(4, CONFIG_SYS_PDM360NG_COPROC_BAUDRATE);
653 if (!cop_port) {
654 printf("Error: Can't open IO Coprocessor port.\n");
655 return -1;
656 }
657
658 debug("%s: cmd: %s", __func__, cmd_buf);
659 write_port(cop_port, cmd_buf);
660
661
662
663
664 udelay(CONFIG_SYS_PDM360NG_COPROC_READ_DELAY);
665 memset(cmd_buf, 0, sizeof(cmd_buf));
666 len = read_port(cop_port, cmd_buf, sizeof(cmd_buf));
667 if (len)
668 printf("Error: %s\n", cmd_buf);
669
670 close_port(4);
671
672 return 0;
673}
674
675static int cmd_lcd_brightness(cmd_tbl_t *cmdtp, int flag,
676 int argc, char * const argv[])
677{
678 if (argc < 2)
679 return cmd_usage(cmdtp);
680
681 return set_lcd_brightness(argv[1]);
682}
683
684U_BOOT_CMD(lcdbr, 2, 1, cmd_lcd_brightness,
685 "set LCD brightness",
686 "<brightness> - set LCD backlight level to <brightness>.\n"
687);
688#endif
689