1 /******************************************************************************
2 * Copyright (c) 2004, 2008 IBM Corporation
4 * This program and the accompanying materials
5 * are made available under the terms of the BSD License
6 * which accompanies this distribution, and is available at
7 * http://www.opensource.org/licenses/bsd-license.php
10 * IBM Corporation - initial implementation
11 *****************************************************************************/
15 #include "rtas_board.h"
18 rtas_ibm_read_pci_config (rtas_args_t *rtas_args)
21 uint64_t addr = ((uint64_t) rtas_args->args[1]) << 32; // high 32 bits of PHB UID
22 addr |= (rtas_args->args[2] & 0xFFFFFFFF); // low 32 bits of PHB UID
23 addr |= (rtas_args->args[0] & 0x00FFFFFF); // bus, devfn, offset
24 unsigned int size = rtas_args->args[3];
26 /* Check for bus != 0 on PCI/PCI-X (PHB UID = 0xf2000000) */
27 if (((addr & 0xf2000000) == 0xf2000000) && (addr & 0xff0000))
31 rtas_args->args[5] = load8_ci(addr);
33 rtas_args->args[5] = bswap16_load(addr);
35 rtas_args->args[5] = bswap32_load(addr);
37 retVal = -3; /* Bad arguments */
39 rtas_args->args[4] = retVal;
43 rtas_ibm_write_pci_config (rtas_args_t *rtas_args)
46 uint64_t addr = ((uint64_t) rtas_args->args[1]) << 32; // high 32 bits of PHB UID
47 addr |= (rtas_args->args[2] & 0xFFFFFFFF); // low 32 bits of PHB UID
48 addr |= (rtas_args->args[0] & 0x00FFFFFF); // bus, devfn, offset
49 unsigned int size = rtas_args->args[3];
53 /* Check for bus != 0 on PCI/PCI-X (PHB UID = 0xf2000000) */
54 if (((addr & 0xf2000000) == 0xf2000000) && (addr & 0xff0000))
58 store8_ci(addr, rtas_args->args[4]);
60 bswap16_store(addr, rtas_args->args[4]);
62 bswap32_store(addr, rtas_args->args[4]);
64 retVal = -3; /* Bad arguments */
66 rtas_args->args[5] = retVal;
70 rtas_read_pci_config (rtas_args_t *rtas_args)
73 unsigned long addr = rtas_args->args[0];
74 unsigned int size = rtas_args->args[1];
77 /* Check for bus != 0 */
82 rtas_args->args[3] = load8_ci(addr);
84 rtas_args->args[3] = bswap16_load(addr);
86 rtas_args->args[3] = bswap32_load(addr);
88 retVal = -3; /* Bad arguments */
90 rtas_args->args[2] = retVal;
94 rtas_write_pci_config (rtas_args_t *rtas_args)
97 unsigned long addr = rtas_args->args[0];
98 unsigned int size = rtas_args->args[1];
102 /* Check for bus != 0 */
107 store8_ci(addr, rtas_args->args[2]);
109 bswap16_store(addr, rtas_args->args[2]);
111 bswap32_store(addr, rtas_args->args[2]);
113 retVal = -3; /* Bad arguments */
115 rtas_args->args[3] = retVal;