| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: ISC |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2014 Broadcom Corporation |
|---|
| 3 | | - * |
|---|
| 4 | | - * Permission to use, copy, modify, and/or distribute this software for any |
|---|
| 5 | | - * purpose with or without fee is hereby granted, provided that the above |
|---|
| 6 | | - * copyright notice and this permission notice appear in all copies. |
|---|
| 7 | | - * |
|---|
| 8 | | - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|---|
| 9 | | - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|---|
| 10 | | - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
|---|
| 11 | | - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|---|
| 12 | | - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
|---|
| 13 | | - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
|---|
| 14 | | - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|---|
| 15 | 4 | */ |
|---|
| 16 | 5 | #include <linux/init.h> |
|---|
| 17 | 6 | #include <linux/of.h> |
|---|
| .. | .. |
|---|
| 27 | 16 | struct brcmf_mp_device *settings) |
|---|
| 28 | 17 | { |
|---|
| 29 | 18 | struct brcmfmac_sdio_pd *sdio = &settings->bus.sdio; |
|---|
| 30 | | - struct device_node *np = dev->of_node; |
|---|
| 19 | + struct device_node *root, *np = dev->of_node; |
|---|
| 31 | 20 | int irq; |
|---|
| 32 | 21 | u32 irqf; |
|---|
| 33 | 22 | u32 val; |
|---|
| 34 | 23 | |
|---|
| 24 | + /* Set board-type to the first string of the machine compatible prop */ |
|---|
| 25 | + root = of_find_node_by_path("/"); |
|---|
| 26 | + if (root) { |
|---|
| 27 | + int i, len; |
|---|
| 28 | + char *board_type; |
|---|
| 29 | + const char *tmp; |
|---|
| 30 | + |
|---|
| 31 | + of_property_read_string_index(root, "compatible", 0, &tmp); |
|---|
| 32 | + |
|---|
| 33 | + /* get rid of '/' in the compatible string to be able to find the FW */ |
|---|
| 34 | + len = strlen(tmp) + 1; |
|---|
| 35 | + board_type = devm_kzalloc(dev, len, GFP_KERNEL); |
|---|
| 36 | + strscpy(board_type, tmp, len); |
|---|
| 37 | + for (i = 0; i < board_type[i]; i++) { |
|---|
| 38 | + if (board_type[i] == '/') |
|---|
| 39 | + board_type[i] = '-'; |
|---|
| 40 | + } |
|---|
| 41 | + settings->board_type = board_type; |
|---|
| 42 | + |
|---|
| 43 | + of_node_put(root); |
|---|
| 44 | + } |
|---|
| 45 | + |
|---|
| 35 | 46 | if (!np || bus_type != BRCMF_BUSTYPE_SDIO || |
|---|
| 36 | 47 | !of_device_is_compatible(np, "brcm,bcm4329-fmac")) |
|---|
| 37 | 48 | return; |
|---|