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> |
James Feist | 053a664 | 2018-10-15 13:17:09 -0700 | [diff] [blame] | 40 | exportTemplates{ |
James Feist | 57cf32d | 2018-10-15 16:15:36 -0700 | [diff] [blame] | 41 | {{"EEPROM", ExportTemplate("eeprom $Address", |
| 42 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
Patrick Venture | 6d4f1f9 | 2019-07-30 18:06:53 -0700 | [diff] [blame] | 43 | {"24C64", ExportTemplate("24c64 $Address", |
| 44 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
James Feist | c1aff3a | 2018-10-26 14:10:34 -0700 | [diff] [blame] | 45 | {"Gpio", ExportTemplate("$Index", "/sys/class/gpio/export")}, |
James Feist | 57cf32d | 2018-10-15 16:15:36 -0700 | [diff] [blame] | 46 | {"PCA9543Mux", |
James Feist | 053a664 | 2018-10-15 13:17:09 -0700 | [diff] [blame] | 47 | ExportTemplate("pca9543 $Address", |
| 48 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
Ed Tanous | bea722b | 2019-01-28 16:22:28 -0800 | [diff] [blame] | 49 | {"PCA9544Mux", |
| 50 | ExportTemplate("pca9544 $Address", |
| 51 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
James Feist | 053a664 | 2018-10-15 13:17:09 -0700 | [diff] [blame] | 52 | {"PCA9545Mux", |
| 53 | ExportTemplate("pca9545 $Address", |
| 54 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
James Feist | 286babc | 2019-02-07 16:48:28 -0800 | [diff] [blame] | 55 | {"PCA9546Mux", |
| 56 | ExportTemplate("pca9546 $Address", |
| 57 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
James Feist | a3f1e72 | 2018-10-15 16:33:03 -0700 | [diff] [blame] | 58 | {"pmbus", ExportTemplate("pmbus $Address", |
| 59 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
James Feist | 053a664 | 2018-10-15 13:17:09 -0700 | [diff] [blame] | 60 | {"TMP75", ExportTemplate("tmp75 $Address", |
James Feist | 57cf32d | 2018-10-15 16:15:36 -0700 | [diff] [blame] | 61 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
James Feist | 053a664 | 2018-10-15 13:17:09 -0700 | [diff] [blame] | 62 | {"TMP421", ExportTemplate("tmp421 $Address", |
Jae Hyun Yoo | 9cdeabb | 2018-10-16 11:47:09 -0700 | [diff] [blame] | 63 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
Patrick Venture | e2785e9 | 2019-08-09 16:04:16 -0700 | [diff] [blame^] | 64 | {"TMP441", ExportTemplate("tmp441 $Address", |
| 65 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
John Wang | 3e20099 | 2019-04-18 14:10:46 +0800 | [diff] [blame] | 66 | {"EMC1413", |
| 67 | ExportTemplate("emc1413 $Address", |
| 68 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}, |
Jae Hyun Yoo | a39ff4b | 2019-08-02 10:15:35 -0700 | [diff] [blame] | 69 | {"TMP112", |
| 70 | ExportTemplate("tmp112 $Address", |
| 71 | "/sys/bus/i2c/devices/i2c-$Bus/new_device")}}}; |
Jae Hyun Yoo | 9cdeabb | 2018-10-16 11:47:09 -0700 | [diff] [blame] | 72 | } // namespace devices |