~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/u-boot/board/esd/ocrtc/cmd_ocrtc.c

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * (C) Copyright 2003
 
3
 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
 
4
 *
 
5
 * SPDX-License-Identifier:     GPL-2.0+
 
6
 */
 
7
 
 
8
#include <common.h>
 
9
#include <command.h>
 
10
#include <pci.h>
 
11
#include <pci_ids.h>
 
12
#include <asm/4xx_pci.h>
 
13
 
 
14
 
 
15
#if defined(CONFIG_CMD_BSP)
 
16
 
 
17
/*
 
18
 * Set device number on pci board
 
19
 */
 
20
int do_setdevice(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
21
{
 
22
        int idx = 1;      /* start at 1 (skip device 0) */
 
23
        pci_dev_t bdf = 0;
 
24
        u32 addr;
 
25
 
 
26
        while (bdf >= 0) {
 
27
                if ((bdf = pci_find_device(PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_405GP, idx++)) < 0) {
 
28
                        break;
 
29
                }
 
30
                printf("Found device nr %d at %x!\n", idx-1, bdf);
 
31
                pci_read_config_dword(bdf, PCI_BASE_ADDRESS_1, &addr);
 
32
                addr &= ~0xf;
 
33
                *(u32 *)addr = (bdf & 0x0000f800) >> 11;
 
34
                printf("Wrote %x at %x!\n", (bdf & 0x0000f800) >> 11, addr);
 
35
        }
 
36
 
 
37
        return 0;
 
38
}
 
39
U_BOOT_CMD(
 
40
        setdevice,      1,      1,      do_setdevice,
 
41
        "Set device number on pci adapter boards",
 
42
        ""
 
43
);
 
44
 
 
45
 
 
46
/*
 
47
 * Get device number on pci board
 
48
 */
 
49
int do_getdevice(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
50
{
 
51
        u32 device;
 
52
        char str[32];
 
53
 
 
54
        device = *(u32 *)0x0;
 
55
        device = 0x16 - device;      /* calculate vxworks bp slot id */
 
56
        sprintf(str, "%d", device);
 
57
        setenv("slot", str);
 
58
        printf("Variabel slot set to %x\n", device);
 
59
 
 
60
        return 0;
 
61
}
 
62
U_BOOT_CMD(
 
63
        getdevice,      1,      1,      do_getdevice,
 
64
        "Get device number and set slot env variable",
 
65
        ""
 
66
);
 
67
 
 
68
#endif