1 /* 2 * Copyright 2018 Hans de Goede <hdegoede@redhat.com> 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 */ 16 17 #include <linux/dmi.h> 18 #include <linux/mod_devicetable.h> 19 #include "core.h" 20 #include "common.h" 21 #include "brcm_hw_ids.h" 22 23 /* The DMI data never changes so we can use a static buf for this */ 24 static char dmi_board_type[128]; 25 26 struct brcmf_dmi_data { 27 u32 chip; 28 u32 chiprev; 29 const char *board_type; 30 }; 31 32 /* NOTE: Please keep all entries sorted alphabetically */ 33 34 static const struct brcmf_dmi_data acepc_t8_data = { 35 BRCM_CC_4345_CHIP_ID, 6, "acepc-t8" 36 }; 37 38 static const struct brcmf_dmi_data gpd_win_pocket_data = { 39 BRCM_CC_4356_CHIP_ID, 2, "gpd-win-pocket" 40 }; 41 42 static const struct brcmf_dmi_data jumper_ezpad_mini3_data = { 43 BRCM_CC_43430_CHIP_ID, 0, "jumper-ezpad-mini3" 44 }; 45 46 static const struct brcmf_dmi_data meegopad_t08_data = { 47 BRCM_CC_43340_CHIP_ID, 2, "meegopad-t08" 48 }; 49 50 static const struct brcmf_dmi_data pov_tab_p1006w_data = { 51 BRCM_CC_43340_CHIP_ID, 2, "pov-tab-p1006w-data" 52 }; 53 54 static const struct dmi_system_id dmi_platform_data[] = { 55 { 56 /* ACEPC T8 Cherry Trail Z8350 mini PC */ 57 .matches = { 58 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "To be filled by O.E.M."), 59 DMI_EXACT_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"), 60 DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "T8"), 61 /* also match on somewhat unique bios-version */ 62 DMI_EXACT_MATCH(DMI_BIOS_VERSION, "1.000"), 63 }, 64 .driver_data = (void *)&acepc_t8_data, 65 }, 66 { 67 /* ACEPC T11 Cherry Trail Z8350 mini PC, same wifi as the T8 */ 68 .matches = { 69 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "To be filled by O.E.M."), 70 DMI_EXACT_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"), 71 DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "T11"), 72 /* also match on somewhat unique bios-version */ 73 DMI_EXACT_MATCH(DMI_BIOS_VERSION, "1.000"), 74 }, 75 .driver_data = (void *)&acepc_t8_data, 76 }, 77 { 78 /* Match for the GPDwin which unfortunately uses somewhat 79 * generic dmi strings, which is why we test for 4 strings. 80 * Comparing against 23 other byt/cht boards, board_vendor 81 * and board_name are unique to the GPDwin, where as only one 82 * other board has the same board_serial and 3 others have 83 * the same default product_name. Also the GPDwin is the 84 * only device to have both board_ and product_name not set. 85 */ 86 .matches = { 87 DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), 88 DMI_MATCH(DMI_BOARD_NAME, "Default string"), 89 DMI_MATCH(DMI_BOARD_SERIAL, "Default string"), 90 DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), 91 }, 92 .driver_data = (void *)&gpd_win_pocket_data, 93 }, 94 { 95 /* Jumper EZpad mini3 */ 96 .matches = { 97 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"), 98 DMI_MATCH(DMI_PRODUCT_NAME, "CherryTrail"), 99 /* jumperx.T87.KFBNEEA02 with the version-nr dropped */ 100 DMI_MATCH(DMI_BIOS_VERSION, "jumperx.T87.KFBNEEA"), 101 }, 102 .driver_data = (void *)&jumper_ezpad_mini3_data, 103 }, 104 { 105 /* Meegopad T08 */ 106 .matches = { 107 DMI_MATCH(DMI_SYS_VENDOR, "Default string"), 108 DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), 109 DMI_MATCH(DMI_BOARD_NAME, "T3 MRD"), 110 DMI_MATCH(DMI_BOARD_VERSION, "V1.1"), 111 }, 112 .driver_data = (void *)&meegopad_t08_data, 113 }, 114 { 115 /* Point of View TAB-P1006W-232 */ 116 .matches = { 117 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Insyde"), 118 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "BayTrail"), 119 /* Note 105b is Foxcon's USB/PCI vendor id */ 120 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "105B"), 121 DMI_EXACT_MATCH(DMI_BOARD_NAME, "0E57"), 122 }, 123 .driver_data = (void *)&pov_tab_p1006w_data, 124 }, 125 {} 126 }; 127 128 void brcmf_dmi_probe(struct brcmf_mp_device *settings, u32 chip, u32 chiprev) 129 { 130 const struct dmi_system_id *match; 131 const struct brcmf_dmi_data *data; 132 const char *sys_vendor; 133 const char *product_name; 134 135 /* Some models have DMI strings which are too generic, e.g. 136 * "Default string", we use a quirk table for these. 137 */ 138 for (match = dmi_first_match(dmi_platform_data); 139 match; 140 match = dmi_first_match(match + 1)) { 141 data = match->driver_data; 142 143 if (data->chip == chip && data->chiprev == chiprev) { 144 settings->board_type = data->board_type; 145 return; 146 } 147 } 148 149 /* Not found in the quirk-table, use sys_vendor-product_name */ 150 sys_vendor = dmi_get_system_info(DMI_SYS_VENDOR); 151 product_name = dmi_get_system_info(DMI_PRODUCT_NAME); 152 if (sys_vendor && product_name) { 153 snprintf(dmi_board_type, sizeof(dmi_board_type), "%s-%s", 154 sys_vendor, product_name); 155 settings->board_type = dmi_board_type; 156 } 157 } 158