Changeset 48935


Ignore:
Timestamp:
2016-03-06T19:08:03+01:00 (2 years ago)
Author:
rmilecki
Message:

bcm53xx: use SPROM driver queued for 4.6

Signed-off-by: Rafał Miłecki <zajec5@…>

Location:
trunk/target/linux/bcm53xx
Files:
2 added
4 deleted
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/target/linux/bcm53xx/files-4.1/drivers/firmware/broadcom/Kconfig

    r43612 r48935  
    1010          It simply reads content of NVRAM and parses it. It doesn't control any 
    1111          hardware part itself. 
     12 
     13config BCM47XX_SPROM 
     14        bool "Broadcom SPROM driver" 
     15        depends on BCM47XX_NVRAM 
     16        help 
     17          Broadcom devices store configuration data in SPROM. Accessing it is 
     18          specific to the bus host type, e.g. PCI(e) devices have it mapped in 
     19          a PCI BAR. 
     20          In case of SoC devices SPROM content is stored on a flash used by 
     21          bootloader firmware CFE. This driver provides method to ssb and bcma 
     22          drivers to read SPROM on SoC. 
  • trunk/target/linux/bcm53xx/files-4.1/drivers/firmware/broadcom/Makefile

    r43612 r48935  
    11obj-$(CONFIG_BCM47XX_NVRAM)             += bcm47xx_nvram.o 
     2obj-$(CONFIG_BCM47XX_SPROM)             += bcm47xx_sprom.o 
  • trunk/target/linux/bcm53xx/files/drivers/firmware/broadcom/bcm47xx_sprom.c

    r48934 r48935  
    2727 */ 
    2828 
    29 #include <linux/types.h> 
    30 #include <linux/module.h> 
    31 #include <linux/kernel.h> 
    32 #include <linux/string.h> 
    33 #include <linux/of_address.h> 
    34 #include <linux/device.h> 
    35 #include <linux/platform_device.h> 
    36 #include <linux/of_platform.h> 
    37 #include <linux/io.h> 
     29#include <linux/bcm47xx_nvram.h> 
     30#include <linux/bcma/bcma.h> 
     31#include <linux/etherdevice.h> 
     32#include <linux/if_ether.h> 
    3833#include <linux/ssb/ssb.h> 
    39 #include <linux/bcma/bcma.h> 
    40 #include <linux/bcm47xx_nvram.h> 
    41 #include <linux/if_ether.h> 
    42 #include <linux/etherdevice.h> 
    4334 
    4435static void create_key(const char *prefix, const char *postfix, 
     
    7263 
    7364#define NVRAM_READ_VAL(type)                                            \ 
    74 static void nvram_read_ ## type (const char *prefix,                    \ 
    75                                  const char *postfix, const char *name, \ 
    76                                  type *val, type allset, bool fallback) \ 
     65static void nvram_read_ ## type(const char *prefix,                     \ 
     66                                const char *postfix, const char *name,  \ 
     67                                type *val, type allset, bool fallback)  \ 
    7768{                                                                       \ 
    7869        char buf[100];                                                  \ 
     
    434425 
    435426        for (i = 0; i < ARRAY_SIZE(sprom->core_pwr_info); i++) { 
    436                 struct ssb_sprom_core_pwr_info *pwr_info = &sprom->core_pwr_info[i]; 
     427                struct ssb_sprom_core_pwr_info *pwr_info; 
     428 
     429                pwr_info = &sprom->core_pwr_info[i]; 
     430 
    437431                snprintf(postfix, sizeof(postfix), "%i", i); 
    438432                nvram_read_u8(prefix, postfix, "maxp2ga", 
     
    482476 
    483477        for (i = 0; i < ARRAY_SIZE(sprom->core_pwr_info); i++) { 
    484                 struct ssb_sprom_core_pwr_info *pwr_info = &sprom->core_pwr_info[i]; 
     478                struct ssb_sprom_core_pwr_info *pwr_info; 
     479 
     480                pwr_info = &sprom->core_pwr_info[i]; 
     481 
    485482                snprintf(postfix, sizeof(postfix), "%i", i); 
    486483                nvram_read_u16(prefix, postfix, "pa2gw3a", 
     
    547544 
    548545        /* The address prefix 00:90:4C is used by Broadcom in their initial 
    549            configuration. When a mac address with the prefix 00:90:4C is used 
    550            all devices from the same series are sharing the same mac address. 
    551            To prevent mac address collisions we replace them with a mac address 
    552            based on the base address. */ 
     546         * configuration. When a mac address with the prefix 00:90:4C is used 
     547         * all devices from the same series are sharing the same mac address. 
     548         * To prevent mac address collisions we replace them with a mac address 
     549         * based on the base address. 
     550         */ 
    553551        if (!bcm47xx_is_valid_mac(sprom->il0mac)) { 
    554552                u8 mac[6]; 
     
    604602} 
    605603 
     604#if defined(CONFIG_SSB_SPROM) 
     605static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out) 
     606{ 
     607        char prefix[10]; 
     608 
     609        switch (bus->bustype) { 
     610        case SSB_BUSTYPE_SSB: 
     611                bcm47xx_fill_sprom(out, NULL, false); 
     612                return 0; 
     613        case SSB_BUSTYPE_PCI: 
     614                memset(out, 0, sizeof(struct ssb_sprom)); 
     615                snprintf(prefix, sizeof(prefix), "pci/%u/%u/", 
     616                         bus->host_pci->bus->number + 1, 
     617                         PCI_SLOT(bus->host_pci->devfn)); 
     618                bcm47xx_fill_sprom(out, prefix, false); 
     619                return 0; 
     620        default: 
     621                pr_warn("Unable to fill SPROM for given bustype.\n"); 
     622                return -EINVAL; 
     623        } 
     624} 
     625#endif 
     626 
     627#if defined(CONFIG_BCMA) 
    606628/* 
    607629 * Having many NVRAM entries for PCI devices led to repeating prefixes like 
     
    619641        int i; 
    620642 
     643        /* Passed prefix has to end with a slash */ 
    621644        if (prefix_len <= 0 || prefix[prefix_len - 1] != '/') 
    622645                return; 
     
    635658} 
    636659 
    637 /* 
    638  * This function has to be called in a very precise moment. It has to be done: 
    639  * 1) After bcma registers flash cores, so we can read NVRAM. 
    640  * 2) Before any code needs SPROM content. 
    641  * 
    642  * This can be achieved only by using bcma callback. 
    643  */ 
    644 static int bcm47xx_sprom_init(struct bcma_bus *bus, struct ssb_sprom *out) 
    645 { 
    646         char prefix[20]; 
     660static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out) 
     661{ 
     662        struct bcma_boardinfo *binfo = &bus->boardinfo; 
     663        struct bcma_device *core; 
     664        char buf[10]; 
     665        char *prefix; 
     666        bool fallback = false; 
    647667 
    648668        switch (bus->hosttype) { 
    649669        case BCMA_HOSTTYPE_PCI: 
    650                 snprintf(prefix, sizeof(prefix), "pci/%u/%u/", 
    651                          pci_domain_nr(bus->host_pci->bus) + 1, 
    652                          bus->host_pci->bus->number); 
    653                 bcm47xx_sprom_apply_prefix_alias(prefix, sizeof(prefix)); 
    654                 bcm47xx_fill_sprom(out, prefix, false); 
     670                memset(out, 0, sizeof(struct ssb_sprom)); 
     671                /* On BCM47XX all PCI buses share the same domain */ 
     672                if (config_enabled(CONFIG_BCM47XX)) 
     673                        snprintf(buf, sizeof(buf), "pci/%u/%u/", 
     674                                 bus->host_pci->bus->number + 1, 
     675                                 PCI_SLOT(bus->host_pci->devfn)); 
     676                else 
     677                        snprintf(buf, sizeof(buf), "pci/%u/%u/", 
     678                                 pci_domain_nr(bus->host_pci->bus) + 1, 
     679                                 bus->host_pci->bus->number); 
     680                bcm47xx_sprom_apply_prefix_alias(buf, sizeof(buf)); 
     681                prefix = buf; 
    655682                break; 
    656683        case BCMA_HOSTTYPE_SOC: 
    657                 bcm47xx_fill_sprom(out, NULL, false); 
     684                memset(out, 0, sizeof(struct ssb_sprom)); 
     685                core = bcma_find_core(bus, BCMA_CORE_80211); 
     686                if (core) { 
     687                        snprintf(buf, sizeof(buf), "sb/%u/", 
     688                                 core->core_index); 
     689                        prefix = buf; 
     690                        fallback = true; 
     691                } else { 
     692                        prefix = NULL; 
     693                } 
    658694                break; 
    659695        default: 
    660                 pr_err("Unable to fill SPROM for given hosttype.\n"); 
     696                pr_warn("Unable to fill SPROM for given bustype.\n"); 
    661697                return -EINVAL; 
    662698        } 
    663699 
     700        nvram_read_u16(prefix, NULL, "boardvendor", &binfo->vendor, 0, true); 
     701        if (!binfo->vendor) 
     702                binfo->vendor = SSB_BOARDVENDOR_BCM; 
     703        nvram_read_u16(prefix, NULL, "boardtype", &binfo->type, 0, true); 
     704 
     705        bcm47xx_fill_sprom(out, prefix, fallback); 
     706 
    664707        return 0; 
    665 }; 
    666  
    667 static int bcm47xx_sprom_probe(struct platform_device *pdev) 
    668 { 
    669         return bcma_arch_register_fallback_sprom(&bcm47xx_sprom_init); 
    670 } 
    671  
    672 static const struct of_device_id bcm47xx_sprom_of_match_table[] = { 
    673         { .compatible = "brcm,bcm47xx-sprom", }, 
    674         {}, 
    675 }; 
    676 MODULE_DEVICE_TABLE(of, bcm47xx_sprom_of_match_table); 
    677  
    678 static struct platform_driver bcm47xx_sprom_driver = { 
    679         .driver = { 
    680                 .owner = THIS_MODULE, 
    681                 .name = "bcm47xx-sprom", 
    682                 .of_match_table = bcm47xx_sprom_of_match_table, 
    683                 /* driver unloading/unbinding currently not supported */ 
    684                 .suppress_bind_attrs = true, 
    685         }, 
    686         .probe = bcm47xx_sprom_probe, 
    687 }; 
    688 module_platform_driver(bcm47xx_sprom_driver); 
    689  
    690 MODULE_AUTHOR("Hauke Mehrtens <hauke@hauke-m.de>"); 
    691 MODULE_LICENSE("GPL v2"); 
     708} 
     709#endif 
     710 
     711static unsigned int bcm47xx_sprom_registered; 
     712 
     713/* 
     714 * On bcm47xx we need to register SPROM fallback handler very early, so we can't 
     715 * use anything like platform device / driver for this. 
     716 */ 
     717int bcm47xx_sprom_register_fallbacks(void) 
     718{ 
     719        if (bcm47xx_sprom_registered) 
     720                return 0; 
     721 
     722#if defined(CONFIG_SSB_SPROM) 
     723        if (ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom_ssb)) 
     724                pr_warn("Failed to registered ssb SPROM handler\n"); 
     725#endif 
     726 
     727#if defined(CONFIG_BCMA) 
     728        if (bcma_arch_register_fallback_sprom(&bcm47xx_get_sprom_bcma)) 
     729                pr_warn("Failed to registered bcma SPROM handler\n"); 
     730#endif 
     731 
     732        bcm47xx_sprom_registered = 1; 
     733 
     734        return 0; 
     735} 
     736 
     737fs_initcall(bcm47xx_sprom_register_fallbacks); 
  • trunk/target/linux/bcm53xx/patches-4.4/112-bcm53xx-sprom-add-sprom-driver.patch

    r47703 r48935  
    2222 create mode 100644 drivers/misc/bcm47xx-sprom.c 
    2323 
    24 --- /dev/null 
    25 +++ b/Documentation/devicetree/bindings/misc/bcm47xx-sprom.txt 
    26 @@ -0,0 +1,16 @@ 
    27 +Broadcom bcm47xx/bcm53xx sprom converter 
     24--- a/drivers/firmware/broadcom/Kconfig 
     25+++ b/drivers/firmware/broadcom/Kconfig 
     26@@ -9,3 +9,14 @@ config BCM47XX_NVRAM 
     27          This driver provides an easy way to get value of requested parameter. 
     28          It simply reads content of NVRAM and parses it. It doesn't control any 
     29          hardware part itself. 
    2830+ 
    29 +This driver provbides an sprom based on a given nvram. 
    30 + 
    31 +Required properties: 
    32 + 
    33 +- compatible : brcm,bcm47xx-sprom 
    34 + 
    35 +- nvram : reference to a nvram driver, e.g. bcm47xx-nvram 
    36 + 
    37 +Example: 
    38 + 
    39 +sprom0: sprom@0 { 
    40 +       compatible = "brcm,bcm47xx-sprom"; 
    41 +       nvram = <&nvram0>; 
    42 +}; 
    43 --- a/drivers/misc/Kconfig 
    44 +++ b/drivers/misc/Kconfig 
    45 @@ -525,6 +525,17 @@ config VEXPRESS_SYSCFG 
    46           bus. System Configuration interface is one of the possible means 
    47           of generating transactions on this bus. 
    48   
    4931+config BCM47XX_SPROM 
    50 +       tristate "BCM47XX sprom driver" 
     32+       bool "Broadcom SPROM driver" 
     33+       depends on BCM47XX_NVRAM 
    5134+       help 
    52 +         This driver parses the sprom from a given nvram which is found on 
    53 +         Broadcom bcm47xx and bcm53xx SoCs. 
    54 + 
    55 +         The sprom contains board configuration data like the 
    56 +         calibration data fro the wifi chips, the mac addresses used 
    57 +         by the board and many other board configuration data. This 
    58 +         driver will provide the sprom to bcma. 
    59 + 
    60  source "drivers/misc/c2port/Kconfig" 
    61  source "drivers/misc/eeprom/Kconfig" 
    62  source "drivers/misc/cb710/Kconfig" 
    63 --- a/drivers/misc/Makefile 
    64 +++ b/drivers/misc/Makefile 
    65 @@ -56,3 +56,4 @@ obj-$(CONFIG_GENWQE)          += genwqe/ 
    66  obj-$(CONFIG_ECHO)             += echo/ 
    67  obj-$(CONFIG_VEXPRESS_SYSCFG)  += vexpress-syscfg.o 
    68  obj-$(CONFIG_CXL_BASE)         += cxl/ 
    69 +obj-$(CONFIG_BCM47XX_SPROM)    += bcm47xx-sprom.o 
     35+         Broadcom devices store configuration data in SPROM. Accessing it is 
     36+         specific to the bus host type, e.g. PCI(e) devices have it mapped in 
     37+         a PCI BAR. 
     38+         In case of SoC devices SPROM content is stored on a flash used by 
     39+         bootloader firmware CFE. This driver provides method to ssb and bcma 
     40+         drivers to read SPROM on SoC. 
     41--- a/drivers/firmware/broadcom/Makefile 
     42+++ b/drivers/firmware/broadcom/Makefile 
     43@@ -1 +1,2 @@ 
     44 obj-$(CONFIG_BCM47XX_NVRAM)            += bcm47xx_nvram.o 
     45+obj-$(CONFIG_BCM47XX_SPROM)            += bcm47xx_sprom.o 
Note: See TracChangeset for help on using the changeset viewer.