source: trunk/target/linux/brcm63xx/patches-2.6.39/500-ssb-add-callback-for-sprom.patch @ 27284

Last change on this file since 27284 was 27284, checked in by florian, 5 years ago

[brcm63xx] remove gpiodev, prefer sysfs gpio

File size: 4.8 KB
  • arch/mips/bcm63xx/boards/board_bcm963xx.c

    a b static struct ssb_sprom bcm63xx_sprom = 
    21282128        .boardflags_lo          = 0x2848, 
    21292129        .boardflags_hi          = 0x0000, 
    21302130}; 
     2131 
     2132int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out) 
     2133{ 
     2134        if (bus->bustype == SSB_BUSTYPE_PCI) { 
     2135                memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom)); 
     2136                return 0; 
     2137        } else { 
     2138                printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n"); 
     2139                return -EINVAL; 
     2140        } 
     2141} 
    21312142#endif 
    21322143 
    21332144/* 
    int __init board_register_devices(void) 
    24032414        if (!board_get_mac_address(bcm63xx_sprom.il0mac)) { 
    24042415                memcpy(bcm63xx_sprom.et0mac, bcm63xx_sprom.il0mac, ETH_ALEN); 
    24052416                memcpy(bcm63xx_sprom.et1mac, bcm63xx_sprom.il0mac, ETH_ALEN); 
    2406                 if (ssb_arch_set_fallback_sprom(&bcm63xx_sprom) < 0) 
    2407                         printk(KERN_ERR "failed to register fallback SPROM\n"); 
     2417                if (ssb_arch_register_fallback_sprom( 
     2418                                &bcm63xx_get_fallback_sprom) < 0) 
     2419                        printk(KERN_ERR PFX "failed to register fallback SPROM\n"); 
    24082420        } 
    24092421#endif 
    24102422 
  • drivers/ssb/pci.c

    a b static int sprom_extract(struct ssb_bus 
    662662static int ssb_pci_sprom_get(struct ssb_bus *bus, 
    663663                             struct ssb_sprom *sprom) 
    664664{ 
    665         const struct ssb_sprom *fallback; 
    666665        int err; 
    667666        u16 *buf; 
    668667 
    static int ssb_pci_sprom_get(struct ssb_ 
    707706                if (err) { 
    708707                        /* All CRC attempts failed. 
    709708                         * Maybe there is no SPROM on the device? 
    710                          * If we have a fallback, use that. */ 
    711                         fallback = ssb_get_fallback_sprom(); 
    712                         if (fallback) { 
    713                                 memcpy(sprom, fallback, sizeof(*sprom)); 
     709                         * Now we ask the arch code if there is some sprom 
     710                         * avaliable for this device in some other storage */ 
     711                        err = ssb_fill_sprom_with_fallback(bus, sprom); 
     712                        if (err) { 
     713                                ssb_printk(KERN_WARNING PFX "WARNING: Using" 
     714                                           " fallback SPROM failed (err %d)\n", 
     715                                           err); 
     716                        } else { 
    714717                                err = 0; 
    715718                                goto out_free; 
    716719                        } 
  • drivers/ssb/sprom.c

    a b  
    1717#include <linux/slab.h> 
    1818 
    1919 
    20 static const struct ssb_sprom *fallback_sprom; 
     20static int(*get_fallback_sprom)(struct ssb_bus *dev, struct ssb_sprom *out); 
    2121 
    2222 
    2323static int sprom2hex(const u16 *sprom, char *buf, size_t buf_len, 
    out: 
    145145} 
    146146 
    147147/** 
    148  * ssb_arch_set_fallback_sprom - Set a fallback SPROM for use if no SPROM is found. 
     148 * ssb_arch_register_fallback_sprom - Registers a method providing a fallback 
     149 * SPROM if no SPROM is found. 
    149150 * 
    150  * @sprom: The SPROM data structure to register. 
     151 * @sprom_callback: The callbcak function. 
    151152 * 
    152  * With this function the architecture implementation may register a fallback 
    153  * SPROM data structure. The fallback is only used for PCI based SSB devices, 
    154  * where no valid SPROM can be found in the shadow registers. 
     153 * With this function the architecture implementation may register a callback 
     154 * handler which wills the SPROM data structure. The fallback is only used for 
     155 * PCI based SSB devices, where no valid SPROM can be found in the shadow registers. 
    155156 * 
    156157 * This function is useful for weird architectures that have a half-assed SSB device 
    157158 * hardwired to their PCI bus. 
    out: 
    163164 * 
    164165 * This function is available for architecture code, only. So it is not exported. 
    165166 */ 
    166 int ssb_arch_set_fallback_sprom(const struct ssb_sprom *sprom) 
     167int ssb_arch_register_fallback_sprom(int (*sprom_callback)(struct ssb_bus *bus, struct ssb_sprom *out)) 
    167168{ 
    168         if (fallback_sprom) 
     169        if (get_fallback_sprom) 
    169170                return -EEXIST; 
    170         fallback_sprom = sprom; 
     171        get_fallback_sprom = sprom_callback; 
    171172 
    172173        return 0; 
    173174} 
    174175 
    175 const struct ssb_sprom *ssb_get_fallback_sprom(void) 
     176int ssb_fill_sprom_with_fallback(struct ssb_bus *bus, struct ssb_sprom *out) 
    176177{ 
    177         return fallback_sprom; 
     178        if (!get_fallback_sprom) 
     179                return -ENOENT; 
     180 
     181        return get_fallback_sprom(bus, out); 
    178182} 
    179183 
    180184/* http://bcm-v4.sipsolutions.net/802.11/IsSpromAvailable */ 
  • drivers/ssb/ssb_private.h

    a b ssize_t ssb_attr_sprom_store(struct ssb_ 
    171171                             const char *buf, size_t count, 
    172172                             int (*sprom_check_crc)(const u16 *sprom, size_t size), 
    173173                             int (*sprom_write)(struct ssb_bus *bus, const u16 *sprom)); 
    174 extern const struct ssb_sprom *ssb_get_fallback_sprom(void); 
     174extern int ssb_fill_sprom_with_fallback(struct ssb_bus *bus, struct ssb_sprom *out); 
    175175 
    176176 
    177177/* core.c */ 
  • include/linux/ssb/ssb.h

    a b extern bool ssb_is_sprom_available(struc 
    404404 
    405405/* Set a fallback SPROM. 
    406406 * See kdoc at the function definition for complete documentation. */ 
    407 extern int ssb_arch_set_fallback_sprom(const struct ssb_sprom *sprom); 
     407extern int ssb_arch_register_fallback_sprom( 
     408                int (*sprom_callback)(struct ssb_bus *bus, 
     409                struct ssb_sprom *out)); 
    408410 
    409411/* Suspend a SSB bus. 
    410412 * Call this from the parent bus suspend routine. */ 
Note: See TracBrowser for help on using the repository browser.