Lines Matching +full:name +full:- +full:prefix
6 * Copyright (C) 2010-2012 Hauke Mehrtens <hauke@hauke-m.de>
36 static void create_key(const char *prefix, const char *postfix, in create_key() argument
37 const char *name, char *buf, int len) in create_key() argument
39 if (prefix && postfix) in create_key()
40 snprintf(buf, len, "%s%s%s", prefix, name, postfix); in create_key()
41 else if (prefix) in create_key()
42 snprintf(buf, len, "%s%s", prefix, name); in create_key()
44 snprintf(buf, len, "%s%s", name, postfix); in create_key()
46 snprintf(buf, len, "%s", name); in create_key()
49 static int get_nvram_var(const char *prefix, const char *postfix, in get_nvram_var() argument
50 const char *name, char *buf, int len, bool fallback) in get_nvram_var() argument
55 create_key(prefix, postfix, name, key, sizeof(key)); in get_nvram_var()
58 if (fallback && err == -ENOENT && prefix) { in get_nvram_var()
59 create_key(NULL, postfix, name, key, sizeof(key)); in get_nvram_var()
66 static void nvram_read_ ## type(const char *prefix, \
67 const char *postfix, const char *name, \
74 err = get_nvram_var(prefix, postfix, name, buf, sizeof(buf), \
80 pr_warn("can not parse nvram name %s%s%s with value %s got %i\n", \
81 prefix, name, postfix, buf, err); \
96 static void nvram_read_u32_2(const char *prefix, const char *name, in NVRAM_READ_VAL()
103 err = get_nvram_var(prefix, NULL, name, buf, sizeof(buf), fallback); in NVRAM_READ_VAL()
108 pr_warn("can not parse nvram name %s%s with value %s got %i\n", in NVRAM_READ_VAL()
109 prefix, name, buf, err); in NVRAM_READ_VAL()
116 static void nvram_read_leddc(const char *prefix, const char *name, in nvram_read_leddc() argument
124 err = get_nvram_var(prefix, NULL, name, buf, sizeof(buf), fallback); in nvram_read_leddc()
129 pr_warn("can not parse nvram name %s%s with value %s got %i\n", in nvram_read_leddc()
130 prefix, name, buf, err); in nvram_read_leddc()
141 static void nvram_read_macaddr(const char *prefix, const char *name, in nvram_read_macaddr() argument
147 err = get_nvram_var(prefix, NULL, name, buf, sizeof(buf), fallback); in nvram_read_macaddr()
151 strreplace(buf, '-', ':'); in nvram_read_macaddr()
156 static void nvram_read_alpha2(const char *prefix, const char *name, in nvram_read_alpha2() argument
162 err = get_nvram_var(prefix, NULL, name, buf, sizeof(buf), fallback); in nvram_read_alpha2()
174 /* This is one-function-only macro, it uses local "sprom" variable! */
176 if (_revmask & BIT(sprom->revision)) \
177 nvram_read_ ## _type(_prefix, NULL, _name, &sprom->_val, \
189 const char *prefix, bool fallback) in bcm47xx_sprom_fill_auto() argument
191 const char *pre = prefix; in bcm47xx_sprom_fill_auto()
410 const char *prefix, bool fallback) in bcm47xx_fill_sprom_path_r4589() argument
415 for (i = 0; i < ARRAY_SIZE(sprom->core_pwr_info); i++) { in bcm47xx_fill_sprom_path_r4589()
418 pwr_info = &sprom->core_pwr_info[i]; in bcm47xx_fill_sprom_path_r4589()
421 nvram_read_u8(prefix, postfix, "maxp2ga", in bcm47xx_fill_sprom_path_r4589()
422 &pwr_info->maxpwr_2g, 0, fallback); in bcm47xx_fill_sprom_path_r4589()
423 nvram_read_u8(prefix, postfix, "itt2ga", in bcm47xx_fill_sprom_path_r4589()
424 &pwr_info->itssi_2g, 0, fallback); in bcm47xx_fill_sprom_path_r4589()
425 nvram_read_u8(prefix, postfix, "itt5ga", in bcm47xx_fill_sprom_path_r4589()
426 &pwr_info->itssi_5g, 0, fallback); in bcm47xx_fill_sprom_path_r4589()
427 nvram_read_u16(prefix, postfix, "pa2gw0a", in bcm47xx_fill_sprom_path_r4589()
428 &pwr_info->pa_2g[0], 0, fallback); in bcm47xx_fill_sprom_path_r4589()
429 nvram_read_u16(prefix, postfix, "pa2gw1a", in bcm47xx_fill_sprom_path_r4589()
430 &pwr_info->pa_2g[1], 0, fallback); in bcm47xx_fill_sprom_path_r4589()
431 nvram_read_u16(prefix, postfix, "pa2gw2a", in bcm47xx_fill_sprom_path_r4589()
432 &pwr_info->pa_2g[2], 0, fallback); in bcm47xx_fill_sprom_path_r4589()
433 nvram_read_u8(prefix, postfix, "maxp5ga", in bcm47xx_fill_sprom_path_r4589()
434 &pwr_info->maxpwr_5g, 0, fallback); in bcm47xx_fill_sprom_path_r4589()
435 nvram_read_u8(prefix, postfix, "maxp5gha", in bcm47xx_fill_sprom_path_r4589()
436 &pwr_info->maxpwr_5gh, 0, fallback); in bcm47xx_fill_sprom_path_r4589()
437 nvram_read_u8(prefix, postfix, "maxp5gla", in bcm47xx_fill_sprom_path_r4589()
438 &pwr_info->maxpwr_5gl, 0, fallback); in bcm47xx_fill_sprom_path_r4589()
439 nvram_read_u16(prefix, postfix, "pa5gw0a", in bcm47xx_fill_sprom_path_r4589()
440 &pwr_info->pa_5g[0], 0, fallback); in bcm47xx_fill_sprom_path_r4589()
441 nvram_read_u16(prefix, postfix, "pa5gw1a", in bcm47xx_fill_sprom_path_r4589()
442 &pwr_info->pa_5g[1], 0, fallback); in bcm47xx_fill_sprom_path_r4589()
443 nvram_read_u16(prefix, postfix, "pa5gw2a", in bcm47xx_fill_sprom_path_r4589()
444 &pwr_info->pa_5g[2], 0, fallback); in bcm47xx_fill_sprom_path_r4589()
445 nvram_read_u16(prefix, postfix, "pa5glw0a", in bcm47xx_fill_sprom_path_r4589()
446 &pwr_info->pa_5gl[0], 0, fallback); in bcm47xx_fill_sprom_path_r4589()
447 nvram_read_u16(prefix, postfix, "pa5glw1a", in bcm47xx_fill_sprom_path_r4589()
448 &pwr_info->pa_5gl[1], 0, fallback); in bcm47xx_fill_sprom_path_r4589()
449 nvram_read_u16(prefix, postfix, "pa5glw2a", in bcm47xx_fill_sprom_path_r4589()
450 &pwr_info->pa_5gl[2], 0, fallback); in bcm47xx_fill_sprom_path_r4589()
451 nvram_read_u16(prefix, postfix, "pa5ghw0a", in bcm47xx_fill_sprom_path_r4589()
452 &pwr_info->pa_5gh[0], 0, fallback); in bcm47xx_fill_sprom_path_r4589()
453 nvram_read_u16(prefix, postfix, "pa5ghw1a", in bcm47xx_fill_sprom_path_r4589()
454 &pwr_info->pa_5gh[1], 0, fallback); in bcm47xx_fill_sprom_path_r4589()
455 nvram_read_u16(prefix, postfix, "pa5ghw2a", in bcm47xx_fill_sprom_path_r4589()
456 &pwr_info->pa_5gh[2], 0, fallback); in bcm47xx_fill_sprom_path_r4589()
461 const char *prefix, bool fallback) in bcm47xx_fill_sprom_path_r45() argument
466 for (i = 0; i < ARRAY_SIZE(sprom->core_pwr_info); i++) { in bcm47xx_fill_sprom_path_r45()
469 pwr_info = &sprom->core_pwr_info[i]; in bcm47xx_fill_sprom_path_r45()
472 nvram_read_u16(prefix, postfix, "pa2gw3a", in bcm47xx_fill_sprom_path_r45()
473 &pwr_info->pa_2g[3], 0, fallback); in bcm47xx_fill_sprom_path_r45()
474 nvram_read_u16(prefix, postfix, "pa5gw3a", in bcm47xx_fill_sprom_path_r45()
475 &pwr_info->pa_5g[3], 0, fallback); in bcm47xx_fill_sprom_path_r45()
476 nvram_read_u16(prefix, postfix, "pa5glw3a", in bcm47xx_fill_sprom_path_r45()
477 &pwr_info->pa_5gl[3], 0, fallback); in bcm47xx_fill_sprom_path_r45()
478 nvram_read_u16(prefix, postfix, "pa5ghw3a", in bcm47xx_fill_sprom_path_r45()
479 &pwr_info->pa_5gh[3], 0, fallback); in bcm47xx_fill_sprom_path_r45()
490 u8 *oui = mac + ETH_ALEN/2 - 1; in bcm47xx_increase_mac_addr()
491 u8 *p = mac + ETH_ALEN - 1; in bcm47xx_increase_mac_addr()
497 p--; in bcm47xx_increase_mac_addr()
503 return -ENOENT; in bcm47xx_increase_mac_addr()
511 const char *prefix, bool fallback) in bcm47xx_fill_sprom_ethernet() argument
515 nvram_read_macaddr(prefix, "et0macaddr", sprom->et0mac, fallback); in bcm47xx_fill_sprom_ethernet()
516 nvram_read_u8(prefix, NULL, "et0mdcport", &sprom->et0mdcport, 0, in bcm47xx_fill_sprom_ethernet()
518 nvram_read_u8(prefix, NULL, "et0phyaddr", &sprom->et0phyaddr, 0, in bcm47xx_fill_sprom_ethernet()
521 nvram_read_macaddr(prefix, "et1macaddr", sprom->et1mac, fallback); in bcm47xx_fill_sprom_ethernet()
522 nvram_read_u8(prefix, NULL, "et1mdcport", &sprom->et1mdcport, 0, in bcm47xx_fill_sprom_ethernet()
524 nvram_read_u8(prefix, NULL, "et1phyaddr", &sprom->et1phyaddr, 0, in bcm47xx_fill_sprom_ethernet()
527 nvram_read_macaddr(prefix, "et2macaddr", sprom->et2mac, fb); in bcm47xx_fill_sprom_ethernet()
528 nvram_read_u8(prefix, NULL, "et2mdcport", &sprom->et2mdcport, 0, fb); in bcm47xx_fill_sprom_ethernet()
529 nvram_read_u8(prefix, NULL, "et2phyaddr", &sprom->et2phyaddr, 0, fb); in bcm47xx_fill_sprom_ethernet()
531 nvram_read_macaddr(prefix, "macaddr", sprom->il0mac, fallback); in bcm47xx_fill_sprom_ethernet()
532 nvram_read_macaddr(prefix, "il0macaddr", sprom->il0mac, fallback); in bcm47xx_fill_sprom_ethernet()
534 /* The address prefix 00:90:4C is used by Broadcom in their initial in bcm47xx_fill_sprom_ethernet()
535 * configuration. When a mac address with the prefix 00:90:4C is used in bcm47xx_fill_sprom_ethernet()
540 if (!bcm47xx_is_valid_mac(sprom->il0mac)) { in bcm47xx_fill_sprom_ethernet()
548 ether_addr_copy(sprom->il0mac, mac); in bcm47xx_fill_sprom_ethernet()
555 static void bcm47xx_fill_board_data(struct ssb_sprom *sprom, const char *prefix, in bcm47xx_fill_board_data() argument
558 nvram_read_u32_2(prefix, "boardflags", &sprom->boardflags_lo, in bcm47xx_fill_board_data()
559 &sprom->boardflags_hi, fallback); in bcm47xx_fill_board_data()
560 nvram_read_u32_2(prefix, "boardflags2", &sprom->boardflags2_lo, in bcm47xx_fill_board_data()
561 &sprom->boardflags2_hi, fallback); in bcm47xx_fill_board_data()
564 void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix, in bcm47xx_fill_sprom() argument
567 bcm47xx_fill_sprom_ethernet(sprom, prefix, fallback); in bcm47xx_fill_sprom()
568 bcm47xx_fill_board_data(sprom, prefix, fallback); in bcm47xx_fill_sprom()
570 nvram_read_u8(prefix, NULL, "sromrev", &sprom->revision, 0, fallback); in bcm47xx_fill_sprom()
573 nvram_read_alpha2(prefix, "ccode", sprom->alpha2, fallback); in bcm47xx_fill_sprom()
574 if (sprom->revision >= 3) in bcm47xx_fill_sprom()
575 nvram_read_leddc(prefix, "leddc", &sprom->leddc_on_time, in bcm47xx_fill_sprom()
576 &sprom->leddc_off_time, fallback); in bcm47xx_fill_sprom()
578 switch (sprom->revision) { in bcm47xx_fill_sprom()
581 bcm47xx_fill_sprom_path_r4589(sprom, prefix, fallback); in bcm47xx_fill_sprom()
582 bcm47xx_fill_sprom_path_r45(sprom, prefix, fallback); in bcm47xx_fill_sprom()
586 bcm47xx_fill_sprom_path_r4589(sprom, prefix, fallback); in bcm47xx_fill_sprom()
590 bcm47xx_sprom_fill_auto(sprom, prefix, fallback); in bcm47xx_fill_sprom()
596 char prefix[10]; in bcm47xx_get_sprom_ssb() local
598 switch (bus->bustype) { in bcm47xx_get_sprom_ssb()
604 snprintf(prefix, sizeof(prefix), "pci/%u/%u/", in bcm47xx_get_sprom_ssb()
605 bus->host_pci->bus->number + 1, in bcm47xx_get_sprom_ssb()
606 PCI_SLOT(bus->host_pci->devfn)); in bcm47xx_get_sprom_ssb()
607 bcm47xx_fill_sprom(out, prefix, false); in bcm47xx_get_sprom_ssb()
611 return -EINVAL; in bcm47xx_get_sprom_ssb()
624 static void bcm47xx_sprom_apply_prefix_alias(char *prefix, size_t prefix_size) in bcm47xx_sprom_apply_prefix_alias() argument
626 size_t prefix_len = strlen(prefix); in bcm47xx_sprom_apply_prefix_alias()
627 size_t short_len = prefix_len - 1; in bcm47xx_sprom_apply_prefix_alias()
632 /* Passed prefix has to end with a slash */ in bcm47xx_sprom_apply_prefix_alias()
633 if (prefix_len <= 0 || prefix[prefix_len - 1] != '/') in bcm47xx_sprom_apply_prefix_alias()
641 if (!strcmp(buf, prefix) || in bcm47xx_sprom_apply_prefix_alias()
642 (short_len && strlen(buf) == short_len && !strncmp(buf, prefix, short_len))) { in bcm47xx_sprom_apply_prefix_alias()
643 snprintf(prefix, prefix_size, "%d:", i); in bcm47xx_sprom_apply_prefix_alias()
651 struct bcma_boardinfo *binfo = &bus->boardinfo; in bcm47xx_get_sprom_bcma()
654 char *prefix; in bcm47xx_get_sprom_bcma() local
657 switch (bus->hosttype) { in bcm47xx_get_sprom_bcma()
663 bus->host_pci->bus->number + 1, in bcm47xx_get_sprom_bcma()
664 PCI_SLOT(bus->host_pci->devfn)); in bcm47xx_get_sprom_bcma()
667 pci_domain_nr(bus->host_pci->bus) + 1, in bcm47xx_get_sprom_bcma()
668 bus->host_pci->bus->number); in bcm47xx_get_sprom_bcma()
670 prefix = buf; in bcm47xx_get_sprom_bcma()
677 core->core_index); in bcm47xx_get_sprom_bcma()
678 prefix = buf; in bcm47xx_get_sprom_bcma()
681 prefix = NULL; in bcm47xx_get_sprom_bcma()
686 return -EINVAL; in bcm47xx_get_sprom_bcma()
689 nvram_read_u16(prefix, NULL, "boardvendor", &binfo->vendor, 0, true); in bcm47xx_get_sprom_bcma()
690 if (!binfo->vendor) in bcm47xx_get_sprom_bcma()
691 binfo->vendor = SSB_BOARDVENDOR_BCM; in bcm47xx_get_sprom_bcma()
692 nvram_read_u16(prefix, NULL, "boardtype", &binfo->type, 0, true); in bcm47xx_get_sprom_bcma()
694 bcm47xx_fill_sprom(out, prefix, fallback); in bcm47xx_get_sprom_bcma()