blob: 73afd7eb9977b4b34d22254aa3f57bb6199a3426 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/drivers/video/nvidia/nv_of.c
3 *
4 * Copyright 2004 Antonino A. Daplas <adaplas @pol.net>
5 *
6 * Based on rivafb-i2c.c
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file COPYING in the main directory of this archive
10 * for more details.
11 */
12
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/module.h>
14#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <linux/delay.h>
16#include <linux/pci.h>
17#include <linux/fb.h>
18
19#include <asm/io.h>
20
21#include <asm/prom.h>
22#include <asm/pci-bridge.h>
23
24#include "nv_type.h"
25#include "nv_local.h"
26#include "nv_proto.h"
27
Benjamin Herrenschmidt85f15032005-11-07 01:00:30 -080028#include "../edid.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
Benjamin Herrenschmidt85f15032005-11-07 01:00:30 -080030int nvidia_probe_of_connector(struct fb_info *info, int conn, u8 **out_edid)
Linus Torvalds1da177e2005-04-16 15:20:36 -070031{
Alexey Dobriyan2d212472005-09-11 04:01:09 +040032 struct nvidia_par *par = info->par;
Benjamin Herrenschmidt85f15032005-11-07 01:00:30 -080033 struct device_node *parent, *dp;
Jeremy Kerrb04e3dd2006-07-12 15:40:40 +100034 const unsigned char *pedid = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 static char *propnames[] = {
Benjamin Herrenschmidt85f15032005-11-07 01:00:30 -080036 "DFP,EDID", "LCD,EDID", "EDID", "EDID1",
37 "EDID,B", "EDID,A", NULL };
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 int i;
39
Benjamin Herrenschmidt85f15032005-11-07 01:00:30 -080040 parent = pci_device_to_OF_node(par->pci_dev);
41 if (parent == NULL)
42 return -1;
43 if (par->twoHeads) {
Jeremy Kerrb04e3dd2006-07-12 15:40:40 +100044 const char *pname;
Benjamin Herrenschmidt85f15032005-11-07 01:00:30 -080045 int len;
46
47 for (dp = NULL;
48 (dp = of_get_next_child(parent, dp)) != NULL;) {
Stephen Rothwell40cd3a42007-05-01 13:54:02 +100049 pname = of_get_property(dp, "name", NULL);
Benjamin Herrenschmidt85f15032005-11-07 01:00:30 -080050 if (!pname)
51 continue;
52 len = strlen(pname);
53 if ((pname[len-1] == 'A' && conn == 1) ||
54 (pname[len-1] == 'B' && conn == 2)) {
55 for (i = 0; propnames[i] != NULL; ++i) {
Stephen Rothwell40cd3a42007-05-01 13:54:02 +100056 pedid = of_get_property(dp,
57 propnames[i], NULL);
Benjamin Herrenschmidt85f15032005-11-07 01:00:30 -080058 if (pedid != NULL)
59 break;
60 }
61 of_node_put(dp);
62 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 }
64 }
65 }
Benjamin Herrenschmidt85f15032005-11-07 01:00:30 -080066 if (pedid == NULL) {
67 for (i = 0; propnames[i] != NULL; ++i) {
Stephen Rothwell40cd3a42007-05-01 13:54:02 +100068 pedid = of_get_property(parent, propnames[i], NULL);
Benjamin Herrenschmidt85f15032005-11-07 01:00:30 -080069 if (pedid != NULL)
70 break;
71 }
72 }
73 if (pedid) {
Alexey Dobriyanbfba7b32006-12-08 02:40:46 -080074 *out_edid = kmemdup(pedid, EDID_LENGTH, GFP_KERNEL);
Benjamin Herrenschmidt85f15032005-11-07 01:00:30 -080075 if (*out_edid == NULL)
76 return -1;
Benjamin Herrenschmidt85f15032005-11-07 01:00:30 -080077 printk(KERN_DEBUG "nvidiafb: Found OF EDID for head %d\n", conn);
78 return 0;
79 }
80 return -1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070081}