0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #include "priv.h"
0024
0025 #include <core/pci.h>
0026
0027 #if defined(__powerpc__)
0028 struct priv {
0029 const void __iomem *data;
0030 int size;
0031 };
0032
0033 static u32
0034 of_read(void *data, u32 offset, u32 length, struct nvkm_bios *bios)
0035 {
0036 struct priv *priv = data;
0037 if (offset < priv->size) {
0038 length = min_t(u32, length, priv->size - offset);
0039 memcpy_fromio(bios->data + offset, priv->data + offset, length);
0040 return length;
0041 }
0042 return 0;
0043 }
0044
0045 static u32
0046 of_size(void *data)
0047 {
0048 struct priv *priv = data;
0049 return priv->size;
0050 }
0051
0052 static void *
0053 of_init(struct nvkm_bios *bios, const char *name)
0054 {
0055 struct nvkm_device *device = bios->subdev.device;
0056 struct pci_dev *pdev = device->func->pci(device)->pdev;
0057 struct device_node *dn;
0058 struct priv *priv;
0059 if (!(dn = pci_device_to_OF_node(pdev)))
0060 return ERR_PTR(-ENODEV);
0061 if (!(priv = kzalloc(sizeof(*priv), GFP_KERNEL)))
0062 return ERR_PTR(-ENOMEM);
0063 if ((priv->data = of_get_property(dn, "NVDA,BMP", &priv->size)))
0064 return priv;
0065 kfree(priv);
0066 return ERR_PTR(-EINVAL);
0067 }
0068
0069 const struct nvbios_source
0070 nvbios_of = {
0071 .name = "OpenFirmware",
0072 .init = of_init,
0073 .fini = (void(*)(void *))kfree,
0074 .read = of_read,
0075 .size = of_size,
0076 .rw = false,
0077 .ignore_checksum = true,
0078 .no_pcir = true,
0079 };
0080 #else
0081 const struct nvbios_source
0082 nvbios_of = {
0083 };
0084 #endif