mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
pci: add basic support for Apple SunGEM
No driver, but we read the MAC address from the chip and write it into the device-tree where Linux and MacOS look for it. We also set the right compatible property for MacOS to pick it up. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
This commit is contained in:
@ -685,6 +685,35 @@ int rtl8139_config_cb(const pci_config_t *config)
|
||||
return eth_config_cb(config);
|
||||
}
|
||||
|
||||
int sungem_config_cb (const pci_config_t *config)
|
||||
{
|
||||
phandle_t ph = get_cur_dev();
|
||||
uint32_t val, *mmio;
|
||||
uint8_t mac[6];
|
||||
ucell virt;
|
||||
|
||||
#define MAC_ADDR0 (0x6080UL/4) /* MAC Address 0 Register */
|
||||
#define MAC_ADDR1 (0x6084UL/4) /* MAC Address 1 Register */
|
||||
#define MAC_ADDR2 (0x6088UL/4) /* MAC Address 2 Register */
|
||||
|
||||
/* Map PCI memory BAR 0 to access the sungem registers */
|
||||
virt = ob_pci_map(config->assigned[0], 0x8000);
|
||||
mmio = (void *)(uintptr_t)virt;
|
||||
|
||||
val = __le32_to_cpu(*(mmio + MAC_ADDR0));
|
||||
mac[5] = val & 0xff;
|
||||
mac[4] = (val >> 8) & 0xff;
|
||||
val = __le32_to_cpu(*(mmio + MAC_ADDR1));
|
||||
mac[3] = val & 0xff;
|
||||
mac[2] = (val >> 8) & 0xff;
|
||||
val = __le32_to_cpu(*(mmio + MAC_ADDR2));
|
||||
mac[1] = val & 0xff;
|
||||
mac[0] = (val >> 8) & 0xff;
|
||||
set_property(ph, "local-mac-address", (char *)mac, 6);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* "Designing PCI Cards and Drivers for Power Macintosh Computers", p. 454
|
||||
*
|
||||
|
||||
@ -134,6 +134,12 @@ static const pci_dev_t eth_devices[] = {
|
||||
0, 0, 0,
|
||||
rtl8139_config_cb, "ethernet",
|
||||
},
|
||||
{
|
||||
PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_GMAC,
|
||||
NULL, "ethernet", NULL, "gmac\0",
|
||||
0, 0, 0,
|
||||
sungem_config_cb, "ethernet",
|
||||
},
|
||||
{
|
||||
/* Virtio-network controller */
|
||||
PCI_VENDOR_ID_REDHAT_QUMRANET, PCI_DEVICE_ID_VIRTIO_NET,
|
||||
|
||||
@ -41,6 +41,7 @@ extern int ebus_config_cb(const pci_config_t *config);
|
||||
extern int i82378_config_cb(const pci_config_t *config);
|
||||
extern int usb_ohci_config_cb(const pci_config_t *config);
|
||||
extern int rtl8139_config_cb(const pci_config_t *config);
|
||||
extern int sungem_config_cb (const pci_config_t *config);
|
||||
|
||||
static inline int pci_compat_len(const pci_dev_t *dev)
|
||||
{
|
||||
|
||||
@ -202,6 +202,7 @@ extern const pci_arch_t *arch;
|
||||
#define PCI_DEVICE_ID_APPLE_UNI_N_I_PCI 0x001e
|
||||
#define PCI_DEVICE_ID_APPLE_UNI_N_PCI 0x001f
|
||||
#define PCI_DEVICE_ID_APPLE_UNI_N_AGP 0x0020
|
||||
#define PCI_DEVICE_ID_APPLE_UNI_N_GMAC 0x0021
|
||||
#define PCI_DEVICE_ID_APPLE_UNI_N_KEYL 0x0022
|
||||
#define PCI_DEVICE_ID_APPLE_KEYL_USB 0x003f
|
||||
#define PCI_DEVICE_ID_APPLE_U3_AGP 0x004b
|
||||
|
||||
Reference in New Issue
Block a user