[ar71xx] add initial profiles
[openwrt.git] / target / linux / generic-2.6 / patches-2.6.27 / 976-ssb_fallback_sprom.patch
1 Index: linux-2.6.28.7/drivers/ssb/pci.c
2 ===================================================================
3 --- linux-2.6.28.7.orig/drivers/ssb/pci.c 2009-02-26 20:37:02.000000000 +0100
4 +++ linux-2.6.28.7/drivers/ssb/pci.c 2009-02-26 20:41:44.000000000 +0100
5 @@ -514,6 +514,7 @@ unsupported:
6 static int ssb_pci_sprom_get(struct ssb_bus *bus,
7 struct ssb_sprom *sprom)
8 {
9 + const struct ssb_sprom *fallback;
10 int err = -ENOMEM;
11 u16 *buf;
12
13 @@ -533,12 +534,23 @@ static int ssb_pci_sprom_get(struct ssb_
14 bus->sprom_size = SSB_SPROMSIZE_WORDS_R4;
15 sprom_do_read(bus, buf);
16 err = sprom_check_crc(buf, bus->sprom_size);
17 - if (err)
18 + if (err) {
19 + /* All CRC attempts failed.
20 + * Maybe there is no SPROM on the device?
21 + * If we have a fallback, use that. */
22 + fallback = ssb_get_fallback_sprom();
23 + if (fallback) {
24 + memcpy(sprom, fallback, sizeof(*sprom));
25 + err = 0;
26 + goto out_free;
27 + }
28 ssb_printk(KERN_WARNING PFX "WARNING: Invalid"
29 " SPROM CRC (corrupt SPROM)\n");
30 + }
31 }
32 err = sprom_extract(bus, sprom, buf, bus->sprom_size);
33
34 +out_free:
35 kfree(buf);
36 out:
37 return err;
38 Index: linux-2.6.28.7/drivers/ssb/sprom.c
39 ===================================================================
40 --- linux-2.6.28.7.orig/drivers/ssb/sprom.c 2009-02-26 20:33:21.000000000 +0100
41 +++ linux-2.6.28.7/drivers/ssb/sprom.c 2009-02-26 20:52:35.000000000 +0100
42 @@ -14,6 +14,9 @@
43 #include "ssb_private.h"
44
45
46 +static const struct ssb_sprom *fallback_sprom;
47 +
48 +
49 static int sprom2hex(const u16 *sprom, char *buf, size_t buf_len,
50 size_t sprom_size_words)
51 {
52 @@ -131,3 +134,36 @@ out:
53 return res;
54 return err ? err : count;
55 }
56 +
57 +/**
58 + * ssb_arch_set_fallback_sprom - Set a fallback SPROM for use if no SPROM is found.
59 + *
60 + * @sprom: The SPROM data structure to register.
61 + *
62 + * With this function the architecture implementation may register a fallback
63 + * SPROM data structure. The fallback is only used for PCI based SSB devices,
64 + * where no valid SPROM can be found in the shadow registers.
65 + *
66 + * This function is useful for weird architectures that have a half-assed SSB device
67 + * hardwired to their PCI bus.
68 + *
69 + * Note that it does only work with PCI attached SSB devices. PCMCIA devices currently
70 + * don't use this fallback.
71 + * Architectures must provide the SPROM for native SSB devices anyway,
72 + * so the fallback also isn't used for native devices.
73 + *
74 + * This function is available for architecture code, only. So it is not exported.
75 + */
76 +int ssb_arch_set_fallback_sprom(const struct ssb_sprom *sprom)
77 +{
78 + if (fallback_sprom)
79 + return -EEXIST;
80 + fallback_sprom = sprom;
81 +
82 + return 0;
83 +}
84 +
85 +const struct ssb_sprom *ssb_get_fallback_sprom(void)
86 +{
87 + return fallback_sprom;
88 +}
89 Index: linux-2.6.28.7/drivers/ssb/ssb_private.h
90 ===================================================================
91 --- linux-2.6.28.7.orig/drivers/ssb/ssb_private.h 2009-02-26 20:36:33.000000000 +0100
92 +++ linux-2.6.28.7/drivers/ssb/ssb_private.h 2009-02-26 20:36:56.000000000 +0100
93 @@ -131,6 +131,7 @@ ssize_t ssb_attr_sprom_store(struct ssb_
94 const char *buf, size_t count,
95 int (*sprom_check_crc)(const u16 *sprom, size_t size),
96 int (*sprom_write)(struct ssb_bus *bus, const u16 *sprom));
97 +extern const struct ssb_sprom *ssb_get_fallback_sprom(void);
98
99
100 /* core.c */
101 Index: linux-2.6.28.7/include/linux/ssb/ssb.h
102 ===================================================================
103 --- linux-2.6.28.7.orig/include/linux/ssb/ssb.h 2009-02-26 20:26:34.000000000 +0100
104 +++ linux-2.6.28.7/include/linux/ssb/ssb.h 2009-02-26 20:32:30.000000000 +0100
105 @@ -339,6 +339,10 @@ extern int ssb_bus_pcmciabus_register(st
106
107 extern void ssb_bus_unregister(struct ssb_bus *bus);
108
109 +/* Set a fallback SPROM.
110 + * See kdoc at the function definition for complete documentation. */
111 +extern int ssb_arch_set_fallback_sprom(const struct ssb_sprom *sprom);
112 +
113 /* Suspend a SSB bus.
114 * Call this from the parent bus suspend routine. */
115 extern int ssb_bus_suspend(struct ssb_bus *bus);
This page took 0.047773 seconds and 5 git commands to generate.