Add overlay logic to Entity Manager

Generate overlays and fixup symbols to map virtual i2c
busses to muxes. Also scan muxes in order as they seem
to get confused if we scan them out of order.

Change-Id: Iec3ed49fca22db8537e4474d9d95cab2da574aef
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/overlay_templates/ADC.template b/overlay_templates/ADC.template
new file mode 100644
index 0000000..a786628
--- /dev/null
+++ b/overlay_templates/ADC.template
@@ -0,0 +1,15 @@
+/dts-v1/;
+/plugin/;
+/ {
+    compatible = "$platform";
+    fragment@0{
+        target-path = "/";
+        __overlay__{
+            iio-hwmon {
+                compatible = "iio-hwmon";
+                oemname$index = "$name";
+            };
+        };
+
+    };
+};
\ No newline at end of file
diff --git a/overlay_templates/IntelFanConnector.template b/overlay_templates/IntelFanConnector.template
new file mode 100644
index 0000000..1e0aad7
--- /dev/null
+++ b/overlay_templates/IntelFanConnector.template
@@ -0,0 +1,19 @@
+/dts-v1/;
+/plugin/;
+/ {
+    compatible = "$platform";
+    fragment@0{
+        target = <&pwm_tacho>;
+        __overlay__{
+            #address-cells = <1>;
+            #size-cells = <0>;
+            status = "okay";
+            oemname$pwm = "$name";
+            fan@$pwm {
+                reg = <$pwm>;
+                aspeed,fan-tach-ch = /bits/ 8 <$tachs>;
+            };
+        };
+
+    };
+};
diff --git a/overlay_templates/IntelFruDevice.template b/overlay_templates/IntelFruDevice.template
new file mode 100644
index 0000000..0ebb322
--- /dev/null
+++ b/overlay_templates/IntelFruDevice.template
@@ -0,0 +1,20 @@
+/dts-v1/;
+/plugin/;
+/ {
+    compatible = "$platform";
+    fragment@0{
+        target = <&i2c$bus>;
+        __overlay__{
+            #address-cells = <1>;
+            #size-cells = <0>;
+            status = "okay";
+            eeprom@$name {
+                compatible = "atmel,24c02";
+                reg = <$address>;
+                oemname1 = "$name";
+                pagesize = <64>;
+            };
+        };
+
+    };
+};
\ No newline at end of file
diff --git a/overlay_templates/PCA9543Mux.template b/overlay_templates/PCA9543Mux.template
new file mode 100644
index 0000000..3a0cb1c
--- /dev/null
+++ b/overlay_templates/PCA9543Mux.template
@@ -0,0 +1,29 @@
+/dts-v1/;
+/plugin/;
+/ {
+    compatible = "$platform";
+    fragment@0{
+        target = <&i2c$bus>;
+        __overlay__{
+            status = "okay";
+            smbus_mux@$name {
+                compatible = "nxp,pca9543";
+                reg = <$address>;
+                #address-cells = <1>;
+                #size-cells = <0>;
+                oemname1 = "$name";
+                $name_0: $name@0 {
+                    #address-cells = <1>;
+                    #size-cells = <0>;
+                    reg = <0>;
+                };
+                $name_1: $name@1 {
+                    #address-cells = <1>;
+                    #size-cells = <0>;
+                    reg = <1>;
+                };
+            };
+        };
+
+    };
+};
diff --git a/overlay_templates/PCA9545Mux.template b/overlay_templates/PCA9545Mux.template
new file mode 100644
index 0000000..930a5ee
--- /dev/null
+++ b/overlay_templates/PCA9545Mux.template
@@ -0,0 +1,39 @@
+/dts-v1/;
+/plugin/;
+/ {
+    compatible = "$platform";
+    fragment@0{
+        target = <&i2c$bus>;
+        __overlay__{
+            status = "okay";
+            smbus_mux@$name {
+                compatible = "nxp,pca9545";
+                reg = <$address>;
+                #address-cells = <1>;
+                #size-cells = <0>;
+                oemname1 = "$name";
+                $name_0: $name@0 {
+                    #address-cells = <1>;
+                    #size-cells = <0>;
+                    reg = <0>;
+                };
+                $name_1: $name@1 {
+                    #address-cells = <1>;
+                    #size-cells = <0>;
+                    reg = <1>;
+                };
+                $name_2: $name@2{
+                    #address-cells = <1>;
+                    #size-cells = <0>;
+                    reg = <2>;
+                };
+                $name_3: $name@3{
+                    #address-cells = <1>;
+                    #size-cells = <0>;
+                    reg = <3>;
+                };
+            };
+        };
+
+    };
+};
diff --git a/overlay_templates/SkylakeCPU.template b/overlay_templates/SkylakeCPU.template
new file mode 100644
index 0000000..feb49e0
--- /dev/null
+++ b/overlay_templates/SkylakeCPU.template
@@ -0,0 +1,64 @@
+/dts-v1/;
+/plugin/;
+/ {
+    compatible = "$platform";
+    fragment@0{
+        target = <&peci_hwmon$cpu_id>;
+        __overlay__{
+            show-core = <$show_core>;
+            dimm-nums = <$dimm_nums>;
+            status = "okay";
+
+            oemname1 = "Die_Temp_CPU$cpu_id";
+            oemname2 = "DTS_Thermal_Margin_CPU$cpu_id";
+            oemname3 = "TControl_CPU$cpu_id";
+            oemname4 = "TThrottle_CPU$cpu_id";
+
+            oemname100 = "Core0_Temp_CPU$cpu_id";
+            oemname101 = "Core1_Temp_CPU$cpu_id";
+            oemname102 = "Core2_Temp_CPU$cpu_id";
+            oemname103 = "Core3_Temp_CPU$cpu_id";
+            oemname104 = "Core4_Temp_CPU$cpu_id";
+            oemname105 = "Core5_Temp_CPU$cpu_id";
+            oemname106 = "Core6_Temp_CPU$cpu_id";
+            oemname107 = "Core7_Temp_CPU$cpu_id";
+            oemname108 = "Core8_Temp_CPU$cpu_id";
+            oemname109 = "Core9_Temp_CPU$cpu_id";
+            oemname110 = "Core10_Temp_CPU$cpu_id";
+            oemname111 = "Core11_Temp_CPU$cpu_id";
+            oemname112 = "Core12_Temp_CPU$cpu_id";
+            oemname113 = "Core13_Temp_CPU$cpu_id";
+            oemname114 = "Core14_Temp_CPU$cpu_id";
+            oemname115 = "Core15_Temp_CPU$cpu_id";
+            oemname116 = "Core16_Temp_CPU$cpu_id";
+            oemname117 = "Core17_Temp_CPU$cpu_id";
+            oemname118 = "Core18_Temp_CPU$cpu_id";
+            oemname119 = "Core19_Temp_CPU$cpu_id";
+            oemname120 = "Core20_Temp_CPU$cpu_id";
+            oemname121 = "Core21_Temp_CPU$cpu_id";
+            oemname122 = "Core22_Temp_CPU$cpu_id";
+            oemname123 = "Core23_Temp_CPU$cpu_id";
+            oemname124 = "Core24_Temp_CPU$cpu_id";
+            oemname125 = "Core25_Temp_CPU$cpu_id";
+            oemname126 = "Core26_Temp_CPU$cpu_id";
+            oemname127 = "Core27_Temp_CPU$cpu_id";
+
+            oemname200 = "DIMM0_Temp_CPU$cpu_id";
+            oemname201 = "DIMM1_Temp_CPU$cpu_id";
+            oemname202 = "DIMM2_Temp_CPU$cpu_id";
+            oemname203 = "DIMM3_Temp_CPU$cpu_id";
+            oemname204 = "DIMM4_Temp_CPU$cpu_id";
+            oemname205 = "DIMM5_Temp_CPU$cpu_id";
+            oemname206 = "DIMM6_Temp_CPU$cpu_id";
+            oemname207 = "DIMM7_Temp_CPU$cpu_id";
+            oemname208 = "DIMM8_Temp_CPU$cpu_id";
+            oemname209 = "DIMM9_Temp_CPU$cpu_id";
+            oemname210 = "DIMM10_Temp_CPU$cpu_id";
+            oemname211 = "DIMM11_Temp_CPU$cpu_id";
+            oemname212 = "DIMM12_Temp_CPU$cpu_id";
+            oemname213 = "DIMM13_Temp_CPU$cpu_id";
+            oemname214 = "DIMM14_Temp_CPU$cpu_id";
+            oemname215 = "DIMM15_Temp_CPU$cpu_id";
+        };
+    };
+};
diff --git a/overlay_templates/Symbol.template b/overlay_templates/Symbol.template
new file mode 100644
index 0000000..7d430b2
--- /dev/null
+++ b/overlay_templates/Symbol.template
@@ -0,0 +1,11 @@
+/dts-v1/;
+/plugin/;
+/ {
+    compatible = "$platform";
+    fragment@0{
+        target-path = "/__symbols__";
+        __overlay__{
+           i2c$bus = "$path";
+        };
+    };
+};
\ No newline at end of file
diff --git a/overlay_templates/TMP421.template b/overlay_templates/TMP421.template
new file mode 100644
index 0000000..3d32d71
--- /dev/null
+++ b/overlay_templates/TMP421.template
@@ -0,0 +1,21 @@
+/dts-v1/;
+/plugin/;
+/ {
+    compatible = "$platform";
+    fragment@0{
+        target = <&i2c$bus>;
+        __overlay__{
+            #address-cells = <1>;
+            #size-cells = <0>;
+            status = "okay";
+            tmp421@$name$name1 {
+                compatible = "ti,tmp421";
+                reg = <$address>;
+                oemname1 = "$name";
+                oemname2 = "$name1";
+                scale = "-3";
+            };
+        };
+
+    };
+};
\ No newline at end of file
diff --git a/overlay_templates/TMP75.template b/overlay_templates/TMP75.template
new file mode 100644
index 0000000..b60e467
--- /dev/null
+++ b/overlay_templates/TMP75.template
@@ -0,0 +1,20 @@
+/dts-v1/;
+/plugin/;
+/ {
+    compatible = "$platform";
+    fragment@0{
+        target = <&i2c$bus>;
+        __overlay__{
+            #address-cells = <1>;
+            #size-cells = <0>;
+            status = "okay";
+            tmp75@$name {
+                compatible = "ti,tmp75";
+                reg = <$address>;
+                oemname1 = "$name";
+                scale = "-3";
+            };
+        };
+
+    };
+};
\ No newline at end of file
diff --git a/overlay_templates/pmbus.template b/overlay_templates/pmbus.template
new file mode 100644
index 0000000..11d2338
--- /dev/null
+++ b/overlay_templates/pmbus.template
@@ -0,0 +1,18 @@
+/dts-v1/;
+/plugin/;
+/ {
+    compatible = "$platform";
+    fragment@0{
+        target = <&i2c$bus>;
+        __overlay__{
+            #address-cells = <1>;
+            #size-cells = <0>;
+            status = "okay";
+            pmbus@$name {
+                compatible = "pmbus";
+                reg = <$address>;
+                oemname1 = "$name";
+            };
+        };
+    };
+};