James Feist | 053a664 | 2018-10-15 13:17:09 -0700 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 2018 Intel Corporation |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #pragma once |
| 18 | #include <boost/container/flat_map.hpp> |
| 19 | |
| 20 | namespace devices |
| 21 | { |
| 22 | |
| 23 | struct CmpStr |
| 24 | { |
James Feist | a465ccc | 2019-02-08 12:51:01 -0800 | [diff] [blame] | 25 | bool operator()(const char* a, const char* b) const |
James Feist | 053a664 | 2018-10-15 13:17:09 -0700 | [diff] [blame] | 26 | { |
| 27 | return std::strcmp(a, b) < 0; |
| 28 | } |
| 29 | }; |
| 30 | |
| 31 | struct ExportTemplate |
| 32 | { |
James Feist | 9813279 | 2019-07-09 13:29:09 -0700 | [diff] [blame] | 33 | ExportTemplate(const char* params, const char* dev) : |
| 34 | parameters(params), device(dev){}; |
James Feist | a465ccc | 2019-02-08 12:51:01 -0800 | [diff] [blame] | 35 | const char* parameters; |
| 36 | const char* device; |
James Feist | 053a664 | 2018-10-15 13:17:09 -0700 | [diff] [blame] | 37 | }; |
| 38 | |
James Feist | a465ccc | 2019-02-08 12:51:01 -0800 | [diff] [blame] | 39 | const boost::container::flat_map<const char*, ExportTemplate, CmpStr> |
Josh Lehan | ce80db7 | 2019-10-09 14:56:35 -0700 | [diff] [blame^] | 40 | exportTemplates{{ |
| 41 | {"EEPROM", ExportTemplate("eeprom $Address", |
Patrick Venture | 7596657 | 2019-08-13 09:28:08 -0700 | [diff] [blame] | 42 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
Josh Lehan | ce80db7 | 2019-10-09 14:56:35 -0700 | [diff] [blame^] | 43 | {"24C02", ExportTemplate("24c02 $Address", |
| 44 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
| 45 | {"24C64", ExportTemplate("24c64 $Address", |
| 46 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
| 47 | {"Gpio", ExportTemplate("$Index", "/sys/class/gpio/export")}, |
| 48 | {"PCA9543Mux", |
| 49 | ExportTemplate("pca9543 $Address", |
| 50 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
| 51 | {"PCA9544Mux", |
| 52 | ExportTemplate("pca9544 $Address", |
| 53 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
| 54 | {"PCA9545Mux", |
| 55 | ExportTemplate("pca9545 $Address", |
| 56 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
| 57 | {"PCA9546Mux", |
| 58 | ExportTemplate("pca9546 $Address", |
| 59 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
| 60 | {"MAX31725", |
| 61 | ExportTemplate("max31725 $Address", |
| 62 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
| 63 | {"pmbus", ExportTemplate("pmbus $Address", |
| 64 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
| 65 | {"MAX34451", |
| 66 | ExportTemplate("max34451 $Address", |
| 67 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
| 68 | {"TMP75", ExportTemplate("tmp75 $Address", |
| 69 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
| 70 | {"TMP175", ExportTemplate("tmp175 $Address", |
Patrick Venture | 6d4f1f9 | 2019-07-30 18:06:53 -0700 | [diff] [blame] | 71 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
Josh Lehan | ce80db7 | 2019-10-09 14:56:35 -0700 | [diff] [blame^] | 72 | {"TMP421", ExportTemplate("tmp421 $Address", |
James Feist | a3f1e72 | 2018-10-15 16:33:03 -0700 | [diff] [blame] | 73 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
Josh Lehan | ce80db7 | 2019-10-09 14:56:35 -0700 | [diff] [blame^] | 74 | {"TMP441", ExportTemplate("tmp441 $Address", |
James Feist | 57cf32d | 2018-10-15 16:15:36 -0700 | [diff] [blame] | 75 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
Josh Lehan | ce80db7 | 2019-10-09 14:56:35 -0700 | [diff] [blame^] | 76 | {"EMC1413", ExportTemplate("emc1413 $Address", |
Patrick Venture | 306b1a4 | 2019-08-14 18:28:56 -0700 | [diff] [blame] | 77 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
Josh Lehan | ce80db7 | 2019-10-09 14:56:35 -0700 | [diff] [blame^] | 78 | {"TMP112", ExportTemplate("tmp112 $Address", |
| 79 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
| 80 | {"ISL68137", |
| 81 | ExportTemplate("isl68137 $Address", |
| 82 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
| 83 | }}; |
Jae Hyun Yoo | 9cdeabb | 2018-10-16 11:47:09 -0700 | [diff] [blame] | 84 | } // namespace devices |